itextsharp

iTextSharp to generate PDF from WPF FixedDocument

这一生的挚爱 提交于 2019-12-02 21:16:23
I have a simple WPF app that displays and prints some reports with a FixedDocument. How can generate PDF's from that, with a free and open solution, such as iTextSharp? A WPF FixedDocument, also known as an XPS document, is a definite improvement over PDF. It has many capabilities that PDF lacks. In most cases it is better to distribute your document as XPS rather than PDF, but sometimes it is necessary to convert from XPS to PDF, for example if you need to open the document on devices that have only PDF support. Unfortunately most free tools to convert from XPS to PDF, such as CutePDF and

itextsharp - Problems reading PDFs with 1 column (page1) and 2 columns (page2)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 20:02:44
问题 My code below is lost when opening PDF file which has only one column on the front page and more than 1 column on other pages. Someone can tell me what I'm doing wrong? Below my code: PdfReader pdfreader = new PdfReader(pathNmArq); ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); for (int page=1; page <= lastPage; page++) { extractText = PdfTextExtractor.GetTextFromPage(pdfreader, page, strategy); extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding

How to set two tables parallelly in itextsharp document?

99封情书 提交于 2019-12-02 19:51:10
问题 How can I set two tables parallelly in a document My sample code for generate pdf is, Document doc = new Document(new Rectangle(288f, 144f), 10, 10, 10, 10); doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream); doc.Open(); PdfPTable table = new PdfPTable(3); table.TotalWidth = 144f; table.LockedWidth = true; PdfPCell cell = new PdfPCell(new Phrase("This is table 1")); cell.Colspan = 3; cell.HorizontalAlignment = 1; table

split huge 40000 page pdf into single pages, itextsharp, outofmemoryexception

谁说胖子不能爱 提交于 2019-12-02 19:33:37
I am getting huge PDF files with lots of data. The current PDF is 350 MB and has about 40000 pages. It would of course have been nice to get smaller PDFs, but this is what I have to work with now :-( I can open it in acrobat reader with some delay when loading but after that acrobat reader is quick. Now I need to split the huge file into single pages, then try to read some recipient data from the pdf pages, and then send the one or two pages that each recipient should get to each particular recipient. Here is my very small code so far using itextsharp: var inFileName = @"huge350MB40000pages

How to add Sticky Notes, Insert Text at cursor, .. Annotations in existing PDF file using iTextSharp with C#?

邮差的信 提交于 2019-12-02 19:24:05
问题 I want to add Annotations comment in existing PDF file using iTextSharp with C#. Please give sample code to add Annotations in existing PDF file. Here PS Script for my Annotation: [/Contents (My Text contents) /Rect [100 600 150 550] /SrcPg 1 /Title (My Title text) /Color [0 0 1] /Subtype /Caret /ANN pdfmark 回答1: The iText(Sharp) example TimetableAnnotations1.java / TimetableAnnotations1.cs from chapter 7 of iText in Action — 2nd Edition shows how to add annotations to existing PDFs in

How can I get the resolution of an embeded image in a PDF using ITextSharp

感情迁移 提交于 2019-12-02 18:53:39
问题 I've built a method that tries to see if the resolution of all the embedded images in a given pdf is at least 300 PPI (print-worthy). What it does is cycle through each image on a page, and compare its width and height to the artbox width and height. It works successfully if there is only one image per page, but when there are multiple, the artbox size includes all of the images, throwing the numbers off. I was hoping that somebody might have some idea of how to get the rectangle size the

Load basefont from resource

China☆狼群 提交于 2019-12-02 17:59:32
问题 I'm trying to use ITextSharp and load a font file inserted in my project as resource. I try different solutions but none of them seems to work, here a sample of what I did: this one cannot load the resource private static BaseFont _bfArial; public static BaseFont BfArial { get { if (_bfArial == null) _bfArial = BaseFont.CreateFont(@"Resources\Images\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); return _bfArial; } } this one gives me an error: "'Identity-H' is not a supported

Set font for all text from Pdfptable with Itextsharp

大兔子大兔子 提交于 2019-12-02 16:53:24
问题 var htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), styles); document.Open(); BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", "Identity-H", BaseFont.EMBEDDED); Font fontNormal = new Font(Vn_Helvetica, 12, Font.NORMAL); foreach (var t in htmlarraylist) { if (t is PdfPTable) { //how set fontNormal all text from Pdfptable ? } document.Add((IElement)t); } document.Close(); Can someone help me please 回答1: Please try by setting font to the PdfPTable

iTextSharp adding new instances of an existing page

三世轮回 提交于 2019-12-02 16:48:17
问题 Let's say I have a three page PDF and all three of them have AcroFields. I need to be able to generate a new PDF with page 2 repeated N number of times. Each new instance of page 2 will need to have the field names modified to make them distinct from the other instances of page 2. Can someone who's solved this problem before provide a syntax example? 回答1: This is explained in the MergeForms2 example. You should split your document into 3 documents each having one page. Use the renameFields()

TextMarginFinder to verify printability

为君一笑 提交于 2019-12-02 16:40:05
问题 I am attempting to use TextMarginFinder to prove that odd and even pages back up correctly when printing. I have based my code on: http://itextpdf.com/examples/iia.php?id=280 The issue I have is that on odd pages I am looking for the box to be aligned to the left showing a 1CM back margin for example, and on an even page I would expect the page box to be aligned to the right also showing a 1CM back margin. Even in the example above this is not the case, but when printed the text does back up