Ema*_*uel 3 c# pdf acrobat itextsharp page-zoom
我希望PDF阅读器(Adobe Reader)打开PDF文件,缩放自动设置为100%.
谢谢!
我在为自己调查iTextSharp时找到了这段代码片段,发现2人指的是Open Actions.我在下面的http://www.developerbarn.com/blogs/richyrich-33.htm中添加了一个片段:
PdfWriter writer = PdfWriter.GetInstance(doc, HttpContext.Current.Response.OutputStream);
//this creates a new destination to send the action to when the document is opened. The zoom in this instance is set to 0.75f (75%). Again I use doc.PageSize.Height to set the y coordinate to the top of the page. PdfDestination.XYZ is a specific PdfDestination Type that allows us to set the location and zoom.
PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 0.75f);
//open our document
doc.Open();
//here you put all the information you want to write to your PDF
//create a new action to send the document to our new destination.
PdfAction action = PdfAction.GotoLocalPage(1, pdfDest, writer);
//set the open action for our writer object
writer.SetOpenAction(action);
//finally, close our document
doc.Close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6183 次 |
| 最近记录: |