itextsharp

iTextSharp creates PDF with blank pages

左心房为你撑大大i 提交于 2019-12-03 14:52:31
I've just added the iTextSharp XMLWorker nuget package (and its dependencies) to my project and I'm trying to convert the HTML from a string into a PDF file, even though no exceptions are being thrown, the PDF file is being generated with two blank pages. Why? The previous version of the code was using just iTextSharp 5.5.8.0 with HTMLWorker and ParseList method, then I switched to Here is the code I'm using: public void ExportToPdf() { string htmlString = ""; Document document = new Document(PageSize.A4, 40, 40, 40, 40); var memoryStream = new MemoryStream(); PdfWriter writer = PdfWriter

Detecting CJK characters in a string (C#)

最后都变了- 提交于 2019-12-03 14:12:41
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 the database and switch to a CJK font when printing out those characters. Would a regex be the best bet

Is it possible to modify PDF Form Field Names?

我的未来我决定 提交于 2019-12-03 13:54:32
问题 Here's the situation. I have a PDF with automatically generated pdf form field names. The problem is that these names are not very user friendly. They look something like : topmostSubform[0].Page1[0].Website_Address[0] I want to be able to change them so that they are something like WebsiteAddress. I have access to ABCPDF and I have experience with iTextSharp, but I have tried using these API's to do this (access form fields and try to rename), but it does not seem as if it is possible. Does

Add table into existing PDF using iTExtsharp

落花浮王杯 提交于 2019-12-03 13:54:28
I have one PDF in that there is one table that table is dynamic and I want to add another table below to that table dynamically in my existing PDF. Is there any way to add the table in existing PDF at specific place that existing table(that is not at the end of document) is completed then I want to add my table. How can I add? Please suggest me some good way. As you can see below image. Thanks, using iTextSharp.text; using iTextSharp.text.pdf; /// Function which will create pdf document and save in the server folder private void ExportDataToPDFTable() { Document doc = new Document(iTextSharp

Is there a straight forward way to append one PDF doc to another using iTextSharp?

寵の児 提交于 2019-12-03 13:15:20
问题 I've scoured the Web looking for examples on how to do this. I've found a few that seem to be a little more involved then they need to be. So my question is, using iTextSharp, is there a fairly concise way to append one PDF document to another one? Optimally this would NOT involve a third file. Just open the first PDF doc, append the second PDF doc to the first and then close them both. 回答1: I really may be missing something, but I did something much simpler. I concede this solution probably

iTextSharp get PDF DPI

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I get the DPI of the PDF that I am reading from my hard drive into iTextSharp? 回答1: PDF's do not necessarily use DPI in their definitions. PDF's allow the document creator to define their own user coordinate space which may or may not map to anything similar to Dots Per Inch. 回答2: Check this How to calculate the correct image size in out pdf using itextsharp ? Conceptually, user space is an infinite plane. Only a small portion of this plane corresponds to the imageable area of the output device: a rectangular region defined by the

Open Generated pdf file through code directly without saving it onto the disk

瘦欲@ 提交于 2019-12-03 08:52:02
I use Sharepoint 2010 and I am developing a web part where on a button click event, a pdf file needs to be generated and opened directly. Should not be saving onto the disk. I tried the below code protected void Button1_OnClick(object sender, EventArgs e) { Document myDoc = new Document(PageSize.A4.Rotate()); try { PdfWriter.GetInstance(myDoc, new FileStream(@"C:\Directory\Test.pdf", FileMode.Create)); myDoc.Open(); myDoc.Add(new Paragraph("Hello World")); } catch (DocumentException ex) { Console.Error.WriteLine(ex.Message); } myDoc.Close(); } I also tried the below code which also generates

How do I scale a PDF page while maintaining orientation with iTextSharp?

北慕城南 提交于 2019-12-03 08:46:19
问题 How do I scale a pdf page, while maintaining rotation in itextsharp? I have the following, but I lose rotation: public static void ScaleToLetter(string inPDF, string outPDF) { PdfReader reader = new PdfReader(inPDF); Document doc = new Document(PageSize.LETTER); Document.Compress = true; PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(outPDF, FileMode.Create)); doc.Open(); PdfContentByte cb = writer.DirectContent; int rotation; PdfImportedPage page; for (int pageNumber = 1;

iTextSharp Password Protected PDF

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: The following question and answer on StackOverflow show how to generate a PDF that cannot be opened without the appropriate password. Password protected PDF using C# I would like to use this framework similarly, but slightly altered to allow my users to "open" the PDF without needing the password, but only allow them to EDIT the PDF if they have the password. Is that possible with iTextSharp? if this matters, I am working in C# 4.0 within a WF 4.0 custom activity. 回答1: Yes, there are two passwords that you can pass to PdfEncryptor

Convert HTML file to PDF file using ITextSharp

心不动则不痛 提交于 2019-12-03 08:09:23
I'd like to accomplish the following: Given the path name of an html file, and the desired pathname of a pdf file, convert the HTML file to PDF using ITextSharp. I've seen plenty of code samples which do close to this but not exactly what I need. I believe my solution will need to use the iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList() function but I'm having trouble getting this to work with an actual HTML file and outputting an actual PDF file. public void GeneratePDF(string htmlFileName, string outputPDFFileName) {...} is the function I'd really like to get working properly.