本文整理汇总了Java中org.apache.pdfbox.pdmodel.PDPage.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java PDPage.setRotation方法的具体用法?Java PDPage.setRotation怎么用?Java PDPage.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.pdmodel.PDPage
的用法示例。
在下文中一共展示了PDPage.setRotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAlternateRowsDocument
import org.apache.pdfbox.pdmodel.PDPage; //导入方法依赖的package包/类
@Test
public void createAlternateRowsDocument() throws Exception {
final PDDocument document = new PDDocument();
final PDPage page = new PDPage(PDRectangle.A4);
page.setRotation(90);
document.addPage(page);
final PDPageContentStream contentStream = new PDPageContentStream(document, page);
// TODO replace deprecated method call
contentStream.concatenate2CTM(0, 1, -1, 0, page.getMediaBox().getWidth(), 0);
final float startY = page.getMediaBox().getWidth() - 30;
(new TableDrawer(contentStream, createAndGetTableWithAlternatingColors(), 30, startY)).draw();
contentStream.close();
document.save("target/alternateRows.pdf");
document.close();
}
示例2: rotate180
import org.apache.pdfbox.pdmodel.PDPage; //导入方法依赖的package包/类
public ActionForward rotate180(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
Document doc = documentDao.getDocument(request.getParameter("document"));
String docdownload = oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
FileInputStream input = new FileInputStream(docdownload + doc.getDocfilename());
PDFParser parser = new PDFParser(input);
parser.parse();
PDDocument pdf = parser.getPDDocument();
int x = 1;
for (Object p : pdf.getDocumentCatalog().getAllPages()) {
PDPage pg = (PDPage)p;
Integer r = (pg.getRotation() != null ? pg.getRotation() : 0);
pg.setRotation((r+180)%360);
ManageDocumentAction.deleteCacheVersion(doc, x);
x++;
}
pdf.save(docdownload + doc.getDocfilename());
pdf.close();
input.close();
return null;
}
示例3: rotate90
import org.apache.pdfbox.pdmodel.PDPage; //导入方法依赖的package包/类
public ActionForward rotate90(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
Document doc = documentDao.getDocument(request.getParameter("document"));
String docdownload = oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
FileInputStream input = new FileInputStream(docdownload + doc.getDocfilename());
PDFParser parser = new PDFParser(input);
parser.parse();
PDDocument pdf = parser.getPDDocument();
int x = 1;
for (Object p : pdf.getDocumentCatalog().getAllPages()) {
PDPage pg = (PDPage)p;
Integer r = (pg.getRotation() != null ? pg.getRotation() : 0);
pg.setRotation((r+90)%360);
ManageDocumentAction.deleteCacheVersion(doc, x);
x++;
}
pdf.save(docdownload + doc.getDocfilename());
pdf.close();
input.close();
return null;
}
示例4: rotate
import org.apache.pdfbox.pdmodel.PDPage; //导入方法依赖的package包/类
public static void rotate(PDDocument doc, PageSelector pages, int degrees) {
for(PDPage p : pages)
p.setRotation(degrees);
}