java a3 套打印_Java - apache PDFBox兩個A3論文到一個A2?
您可能希望它根據(jù)其的JavaDoc看PageCombinationSample.java確實(shí)幾乎你所需要的:
此示例演示如何多頁(yè)合併成單一的大頁(yè)(例如 兩張A4模塊到一個(gè)A3模塊)使用表單XObjects [PDF:1.6:4.9]。
表單XObjects是一種在多個(gè)頁(yè)面上多次顯示內(nèi)容的便捷方式,如 模板。
中央代碼:
// 1. Opening the source PDF file...
File sourceFile = new File(filePath);
// 2. Instantiate the target PDF file!
File file = new File();
// 3. Source page combination into target file.
Document document = file.getDocument();
Pages pages = document.getPages();
int pageIndex = -1;
PrimitiveComposer composer = null;
Dimension2D targetPageSize = PageFormat.getSize(SizeEnum.A4);
for(Page sourcePage : sourceFile.getDocument().getPages())
{
pageIndex++;
int pageMod = pageIndex % 2;
if(pageMod == 0)
{
if(composer != null)
{composer.flush();}
// Add a page to the target document!
Page page = new Page(
document,
PageFormat.getSize(SizeEnum.A3, OrientationEnum.Landscape)
); // Instantiates the page inside the document context.
pages.add(page); // Puts the page in the pages collection.
// Create a composer for the target content stream!
composer = new PrimitiveComposer(page);
}
// Add the form to the target page!
composer.showXObject(
sourcePage.toXObject(document), // Converts the source page into a form inside the target document.
new Point2D.Double(targetPageSize.getWidth() * pageMod, 0),
targetPageSize,
XAlignmentEnum.Left,
YAlignmentEnum.Top,
0
);
}
composer.flush();
// 4. Serialize the PDF file!
serialize(file, "Page combination", "combining multiple pages into single bigger ones", "page combination");
// 5. Closing the PDF file...
sourceFile.close();
總結(jié)
以上是生活随笔為你收集整理的java a3 套打印_Java - apache PDFBox兩個A3論文到一個A2?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python2升级python3后_Ce
- 下一篇: 维德拉内格雷干红葡萄酒价格多少有人知道吗