使用默认“缩放到页面级别”创建PDF文件(pdfbox)

时间:2016-02-25 06:14:42

标签: java pdf pdf-generation pdfbox

我使用pdfbox 2.0创建PDF文件。当我在Adobe阅读器(Windows)中打开此pdf文件时,默认情况下它以缩放// // ViewController2.swift // MYP_TruthOrDare? // // import UIKit class ViewController2: UIViewController { var countd = 15 @IBOutlet weak var Timer: UILabel! // // override func viewDidLoad() { super.viewDidLoad() Timer.text = String(countd) // var time:NSTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("updateCounter"), userInfo: nil, repeats: true) func updateCounter() { Timer.text = String(countd) if (countd > 0){ Timer.text = String(countd--) Timer.text = String(countd) } } } // Do any additional setup after loading the view. override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } */ } 打开。

enter image description here

我需要使用默认fit width打开pdf文件。

enter image description here

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

zoom to page level

1 个答案:

答案 0 :(得分:3)

使用PDPageFitDestination而不是PDPageXYZDestination - 所以你的代码现在看起来像这样:

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