日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java a3 套打印_Java - apache PDFBox兩個A3論文到一個A2?

發布時間:2024/10/12 java 74 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java a3 套打印_Java - apache PDFBox兩個A3論文到一個A2? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

您可能希望它根據其的JavaDoc看PageCombinationSample.java確實幾乎你所需要的:

此示例演示如何多頁合併成單一的大頁(例如 兩張A4模塊到一個A3模塊)使用表單XObjects [PDF:1.6:4.9]。

表單XObjects是一種在多個頁面上多次顯示內容的便捷方式,如 模板。

中央代碼:

// 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();

總結

以上是生活随笔為你收集整理的java a3 套打印_Java - apache PDFBox兩個A3論文到一個A2?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。