使用默认的“缩放到页面级别"创建PDF文件. (pdfbox) [英] Create PDF file with default "zoom to page level" (pdfbox)

查看:378
本文介绍了使用默认的“缩放到页面级别"创建PDF文件. (pdfbox)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用pdfbox 2.0创建PDF文件.当我在Adobe Reader(Windows)中打开此pdf文件时,默认情况下使用缩放fit width打开.

I create a PDF file using pdfbox 2.0. when i open this pdf file in Adobe reader (windows), by default its open with zoom fit width.

我需要使用默认zoom to page level打开的pdf文件.

What I need pdf file open with default zoom to page level.

我的尝试:
将缩放级别设置为100.

My try:
Set zoom level at 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-这样您的代码现在看起来像这样:

Use PDPageFitDestination instead of PDPageXYZDestination - so your code looks like this now:

PDPageFitDestination dest = new PDPageFitDestination();
PDActionGoTo action = new PDActionGoTo();    
action.setDestination(dest);    
document.getDocumentCatalog().setOpenAction(action);

这篇关于使用默认的“缩放到页面级别"创建PDF文件. (pdfbox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆