使用默认 "zoom to page level" 创建 PDF 文件 (pdfbox)
Create PDF file with default "zoom to page level" (pdfbox)
我使用 pdfbox 2.0 创建了一个 PDF 文件。当我在 Adobe reader (windows) 中打开此 pdf 文件时,默认情况下它以缩放 fit width
打开。
我需要用默认 zoom to page level
打开 pdf 文件。
我的尝试:
将缩放级别设置为 100。
PDPageXYZDestination dest = new PDPageXYZDestination();
dest.setPage(pagea);
dest.setZoom(1);
dest.setTop(new Float(PDRectangle.A4.getHeight()).intValue());
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);
使用 PDPageFitDestination 而不是 PDPageXYZDestination - 所以您的代码现在看起来像这样:
PDPageFitDestination dest = new PDPageFitDestination();
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);
我使用 pdfbox 2.0 创建了一个 PDF 文件。当我在 Adobe reader (windows) 中打开此 pdf 文件时,默认情况下它以缩放 fit width
打开。
我需要用默认 zoom to page level
打开 pdf 文件。
我的尝试:
将缩放级别设置为 100。
PDPageXYZDestination dest = new PDPageXYZDestination();
dest.setPage(pagea);
dest.setZoom(1);
dest.setTop(new Float(PDRectangle.A4.getHeight()).intValue());
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);
使用 PDPageFitDestination 而不是 PDPageXYZDestination - 所以您的代码现在看起来像这样:
PDPageFitDestination dest = new PDPageFitDestination();
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);