itextsharp

How can I override PDF print dialog settings with iTextSharp

左心房为你撑大大i 提交于 2020-01-05 04:50:09
问题 Can any one tell me how to override page orientation selection in pdf print dialog using iTextSharp. I am using these lines to override scaling and "Choose paper source by PDF page size" writer.AddViewerPreference(PdfName.PRINTSCALING,PdfName.NONE); writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFFALSE); 回答1: Please check table 150, entitled "Entries in a viewer preferences dictionary", in ISO-32000-1 (you can download a copy from the Adobe web site). It contains all the

Signing a pdf document

ぃ、小莉子 提交于 2020-01-04 11:39:20
问题 Currently I am upgrading my old application Which is done using itextsharp 5.0.0 to 5.4.5(latest)... But I have a problem in getting the equivalent code for PdfSignatureAppearance.SetCrypto(this.myCert.Akp, this.myCert.Chain, null, PdfSignatureAppearance.SELF_SIGNED); Can anyone help me regarding this? Thanks in advance... 回答1: I sign PDF documents using 5.5 version of iTextSharp. Below is the sample code. // Set the reader (PdfReader) and output (Stream) first PdfStamper stamper = PdfStamper

How to change a Button Icon of a PDF Formular with itextsharp?

柔情痞子 提交于 2020-01-04 07:01:33
问题 I'am currently trying to fill out a predefined Form with itextsharp. All works well except adding an image. This worked already before with the FDF toolkit from Adobe, which was compiled into .NET 1.1. This isn't working with .NET 4.0 anymore and I switched to itextsharp. The way the image was added previously was by changing the icon of a button in a predefined form. That rotateted and scaled the image correctly. Unfortunatly I couldn't find any Method to do this with itextsharp. The code

Change PDF Annotation properties using iTextSharp C#

余生颓废 提交于 2020-01-04 06:11:15
问题 Hi I am adding a caret annotation to an already existing PDF using iTextSharp in C#. Now I want to change some of the annotation's properties, such as Opacity of color and Locked . 回答1: Suppose that you have a PdfAnnotation object. This is a class that extends PdfDictionary . To lock the annotation defined by this annotation dictionary, you need to set the PdfAnnotation.FLAGS_LOCKED flag, for instance with the setFlags() method: annot.setFlags(PdfAnnotation.FLAGS_LOCKED); Note that using this

Extract Embedded XML from PDF with iTextSharp (C#)

∥☆過路亽.° 提交于 2020-01-03 15:34:29
问题 I need to extract XML data embedded in Bankruptcy court files with C#. In PDF Reader the file looks like a typical court doc. In Notepad the XML is buried in the text. I've tried extracting the text with this and another code snippet using SimpleTextExtractionStrategy. The first results in a file with no identifiable text from the PDF and the second outputs symbols. I also tried accessing it as an AcroField and Xfaform. It doesn't seem to be either of those based on the Watch window. Stepping

iTextSharp: “The document is not open” error - when it actually is

China☆狼群 提交于 2020-01-03 12:26:08
问题 I have this code: private static byte[] ConvertPdfDocument(Document document, PdfPTable headerTable, PdfPTable affidavitsTable) { byte[] b; using (MemoryStream ms = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(document, ms); if (document.IsOpen() == false) { document.Open(); } document.Add(headerTable); document.Add(affidavitsTable); document.Close(); writer.Close(); b = ms.ToArray(); } return b; } The "document" object is opened (using document.Open() outside of this method

iTextSharp: “The document is not open” error - when it actually is

亡梦爱人 提交于 2020-01-03 12:24:47
问题 I have this code: private static byte[] ConvertPdfDocument(Document document, PdfPTable headerTable, PdfPTable affidavitsTable) { byte[] b; using (MemoryStream ms = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(document, ms); if (document.IsOpen() == false) { document.Open(); } document.Add(headerTable); document.Add(affidavitsTable); document.Close(); writer.Close(); b = ms.ToArray(); } return b; } The "document" object is opened (using document.Open() outside of this method

Changing PDF crop/media box using iTextSharp

偶尔善良 提交于 2020-01-03 05:21:08
问题 I am trying to to change the media/crop box of an existing PDF using the code below. Document document = new Document(); FileStream outputStream = new FileStream(outFile, FileMode.Create); PdfCopy copy = new PdfSmartCopy(document, outputStream); document.Open(); foreach (string inFile in inFiles) { PdfReader reader = new PdfReader(inFile); float height = Utilities.MillimetersToPoints(388); float width = Utilities.MillimetersToPoints(176); Rectangle newMedia = new Rectangle(height, width);

iText parser exception for XML -> PDF conversion

五迷三道 提交于 2020-01-03 04:24:07
问题 I have a basic .vm file which I populate with XML, and then use iText to convert it to a PDF doc: <?xml version="1.0" encoding="UTF-8"?> <!--<!DOCTYPE itext SYSTEM "http://itext.sourceforge.net/itext.dtd">--> <itext creationdate='${System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss")}' producer="X"> <paragraph align="Default" size="18.0" style="bold" indentationleft="0.0"> Test </paragraph> </itext> The above is parsed absolutely fine. However something slightly more complicated: <?xml version

Error in converting aspx page to html (itextsharp 5.0.6)

假如想象 提交于 2020-01-02 19:16:06
问题 I use this code to convert my aspx page to pdf using itextsharp 5.0.6: Using ms = New MemoryStream() Dim Html As String = vbCr & vbLf & "<h1>h1</h1>" & vbCr & vbLf & "<p class=""bo"">A paragraph</p> " & vbCr & vbLf & "<ul> " & vbCr & vbLf & "<li>one</li> " & vbCr & vbLf & "<li>two</li> " & vbCr & vbLf & "<li>three</li> " & vbCr & vbLf & "</ul>" Dim Html1 As String = RenderControlToString(Page) Dim styles As New StyleSheet() styles.LoadStyle("bo", "size", "10") styles.LoadTagStyle(HtmlTags.H1,