itextsharp

How to extract highlighed text from PDF using iTextSharp?

谁说我不能喝 提交于 2019-12-05 04:27:35
问题 As per folowing post: iTextSharp PDF Reading highlighed text (highlight annotations) using C# this code: for (int i = pageFrom; i <= pageTo; i++) { PdfDictionary page = reader.GetPageN(i); PdfArray annots = page.GetAsArray(iTextSharp.text.pdf.PdfName.ANNOTS); if (annots!=null) foreach (PdfObject annot in annots.ArrayList) { PdfDictionary annotation = (PdfDictionary)PdfReader.GetPdfObject(annot); PdfString contents = annotation.GetAsString(PdfName.CONTENTS); // now use the String value of

iText - how to add pages to a document created with PdfCopy

冷暖自知 提交于 2019-12-05 04:17:02
I am using iText (specifically iTextSharp 4.1.6) and I want to create a PDF by combining pages from existing PDFs but also inserting new pages created from an image. I have got these two parts working separately using PdfCopy and PdfWriter respectively. The code to create a page from an image looks like this: PdfWriter pw = PdfWriter.GetInstance(doc, outputStream); Image img = Image.GetInstance(inputStream); doc.Add(img); doc.NewPage(); Now, Since PdfCopy inherits from PdfWriter, I thought I would be able to add such "image pages" to my PdfCopy object using the same technique, but it doesn't

How do I add images to a PDF with ITextSharp?

假装没事ソ 提交于 2019-12-05 02:49:27
问题 I want to work with iTextSharp 5.0.5. But did not find any tutorial on this version. I downloaded some previous version tutorials but giving error. I just want to stitch some images into a pdf file by iTextSharp. Can anyone please give me code for that ? EDIT: After some time spending on it I finally figured it out how to add image. But the problem is that image is too big. Now my problem is how to shrink image or I want to see the image in page in normal format. Now how can I do it ? 回答1:

.NET version or port of Flying Saucer

浪尽此生 提交于 2019-12-05 02:39:19
Is there any open source .NET project (or port) similar to the Flying Saucer project which renders HTML to PDF using iText ? I always recommend wkHTMLtoPDF for web->PDF conversions. It's web kit based though I'm not sure what PDF library it's sitting on. At any rate, you'll be hard pressed to find something that will render your HTML more accurately (it'll even run script, set innerHtml and so forth). For a quick-and-dirty solution you could try using IKVM to compile the Java to .NET. http://www.ikvm.net/ Use the Pechkin .NET wrapper for WkHtmlToPdf. The resulting pdf can be outputted as a

iTextSharp Efficient Batch Pdf Generation From a 1 Page Template

十年热恋 提交于 2019-12-05 01:03:06
问题 I am generating a multiple page PDF using ITextSharp, each page having the sames template. The problem is that the PDF grows in Phisical Size by the size of the template. I HAVE to use ACROFIELDS . How can I reduce the final file size ? Here is a code snippet of the pdf handler: public void ProcessRequest(HttpContext context) { Context = context; Response = context.Response; Request = context.Request; try { LoadDataInternal(); } catch (System.Threading.ThreadAbortException) { // no-op } catch

Set page margins with iTextSharp

本秂侑毒 提交于 2019-12-04 22:47:11
I have a template PDF file that has a a PDF form field embedded in. I am using PdfStamper to fill out these fields. In addition, I would like to be able to change the margins for generated PDF. is there any way I can modify the page margins on the stamped PDF? You can do it all in one line. Document doc = new Document(PageSize.LETTER, 0f, 0f, 0f, 0f ); Only way I know of is like this. iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(pageWidth, pageHeight); Document doc = new Document(rec); doc.SetMargins(0f, 0f, 0f, 0f); However, this will limit margins too setMaring Impelemented

Detecting CJK characters in a string (C#)

十年热恋 提交于 2019-12-04 22:15:19
问题 I am using iTextSharp to generate a series of PDFs, using Open Sans as the default font. On occasion, names are inserted into the content of the PDFs. However my issue is that some of the names I need to insert contain CJK characters (stored in nvarchar columns in SQL Server), and as far as I know Open Sans does not support CJK characters at present. I need to keep using Open Sans as my default font, so ideally I would like to try and detect CJK characters in the strings being grabbed from

How to detect newline from PDF using iTextSharp [closed]

别来无恙 提交于 2019-12-04 20:50:15
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have used getbaseline[vector.I2] for calculating subscript and superscript. By doing this I'm not able to extract newline from PDF. Can you please suggest to me how to get newline from PDF using iTextSharp? The code you supplied isn't

PdfPTable cell width

懵懂的女人 提交于 2019-12-04 20:32:02
I'm using iTextSharp to create PDFs in my application. However I have to recreate a table, where I have to set the size for a very small column. Below is the picture that shows the size I want to set the column: When the rest of the table creation all is well, I can't set this width . Code: PdfPTable table = new PdfPTable(2); table.WidthPercentage = 82.0f; PdfPCell cell = new PdfPCell(new Phrase("Com a assinatura autógrafa, o signatário desta Auto-declaração garante ter cumprido estas condições:", fontetexto)); cell.PaddingBottom = 10f; cell.PaddingTop = 10f; cell.Colspan = 2; cell

C#利用iTextSharp将datatable数据转化为PDF文件

白昼怎懂夜的黑 提交于 2019-12-04 20:29:39
1、下载iTextSharp.dll文件 下载链接:https://pan.baidu.com/s/14o-pJ-U2yU8n0EyIn249qg 提取码:tklu 2、PDF转换方法 /// <summary> /// datatable转PDF方法 /// </summary> /// <param name="Data">dataTable数据</param> /// <param name="PDFFile">PDF文件保存的路径</param> /// <param name="FontSize">字体大小</param> /// <returns></returns> public bool ConvertDataTableToPDF(DataTable Data, string PDFFile, float FontSize) { //默认页面大小 Document document = new Document(); document.SetPageSize(PageSize.A2); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(PDFFile, FileMode.Create)); document.Open(); //设置字体 //BaseFont bf = BaseFont