itextsharp

itextsharp: splitted pages size equals file size

杀马特。学长 韩版系。学妹 提交于 2019-12-01 08:08:09
问题 Here is how I split large pdf (144 mb) public int SplitAndSave(string inputPath, string outputPath) { FileInfo file = new FileInfo(inputPath); string name = file.Name.Substring(0, file.Name.LastIndexOf(".")); using (PdfReader reader = new PdfReader(inputPath)) { for (int pagenumber = 1; pagenumber <= reader.NumberOfPages; pagenumber++) { string filename = pagenumber.ToString() + ".pdf"; Document document = new Document(); PdfCopy copy = new PdfCopy(document, new FileStream(outputPath + "\\" +

how to save pdf on server map path using iTextsharp

谁说我不能喝 提交于 2019-12-01 08:06:36
i am using following code for generate pdf and it is work perfect: string strQuery = "select * from userdata"; SqlCommand cmd = new SqlCommand(strQuery); DataTable dt = GetData(cmd); //Create a dummy GridView GridView GridView1 = new GridView(); GridView1.AllowPaging = false; GridView1.DataSource = dt; GridView1.DataBind(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw);

How to resize an iTextSharp.text.Image size into my code?

爷,独闯天下 提交于 2019-12-01 08:04:26
I am pretty new in iText nd iTextSharp (the C# version of iText) and I have the following problem. I am inserting some jpg charts inside my PDF. These charts are rapresented by some jpg like this one: I insert it into a table of my PDF in this way: iTextSharp.text.Image img = null; .......................................... .......................................... .......................................... if (currentVuln.UrgencyRating > 0) { img = ChartHelper.GetPdfChartV2((int)currentVuln.UrgencyRating * 10, _folderImages); vulnerabilityDetailsTable.AddCell(new PdfPCell(img) { Border =

How to Check PDF is Reader enabled or not using C#?

天涯浪子 提交于 2019-12-01 08:02:26
问题 My only requirement is to find a selected pdf in a folder is Reader enabled or not, more specifically if usage rights are defined in a way that allows people to add annotations (e.g. comments). I am doing this in windows application. If I click a button, an event is triggered searching a folder for PDF files. This event needs to check whether or not the PDFs in the folder are Reader enabled for comments. If they are, I need to remove the comment usage rights or revert the PDF back to its

Extract paths and shapes with iTextSharp

本秂侑毒 提交于 2019-12-01 07:28:22
问题 iTextSharp supports creation of shapes and paths with PdfContentByte class, there you can set colors and paint curves and basic elements ... is there a mechanism which does the other way? I am able to get content by calling PdfReader.GetPageContent(...) but I didn't find a "parser" to read those operations, apply them to graphics context and for example paint it on a panel. Example: 1 1 1 RG 1 1 1 rg 0.12 0 0 0.12 16 31 cm q 480 421 m 4318 421 l 4318 5459 l 480 5459 l 480 421 l W n 0

Chart and graphs

巧了我就是萌 提交于 2019-12-01 07:25:29
问题 I am using iTextSharp version 4.1.2 and cannot update to newer version because iText changed their licence agreement. I am very satisfied with this version and it's working fine for me. I can't find anywhere how to produce pie or bar or columns graphs and charts with that version and looks like all documentation over the internet been removed. If you are using older version and by the chance you have documentation can you please share or point me to the source, or explain how? 回答1: iText

“The document is not open” error only in production with iTextSharp

无人久伴 提交于 2019-12-01 06:27:12
问题 I am getting a "The document is not open" error in iTextSharp, but only in production. The code runs fine on my dev machine and in staging. I have the same permissions set in the Temp folder on the stage server. public static byte[] ConvertHtmlToPdf(string html) { html = HtmlPostProcessor.Process(html); byte[] fileData = null; string tempPath = ConfigurationManager.AppSettings["TempDirectory"]; string tempPDFFile = Path.Combine(tempPath, Guid.NewGuid() + ".pdf"); int num = FontFactory

Alter PDF - Text repositioning

自闭症网瘾萝莉.ら 提交于 2019-12-01 06:26:02
Is there any way to shift / move the text inside existing pdf page to some other position ? Like there is some text at area x=100, y=100, w=100, h=100 and i want to move it to x=50, y=200, w=100, h=100. I did a lot of research and it seems iTextSharp cannot do that. PDFSharp claims that it can be done but i could not find any examples. One way is to make a bitmap of specific area of the text i want to shift, draw white rectangle over that area and insert bitmap at new location. I don't want to use this solution as i work with large pdf files with more than 1K pages where each page has to be

How to resize an iTextSharp.text.Image size into my code?

一笑奈何 提交于 2019-12-01 06:25:31
问题 I am pretty new in iText nd iTextSharp (the C# version of iText) and I have the following problem. I am inserting some jpg charts inside my PDF. These charts are rapresented by some jpg like this one: I insert it into a table of my PDF in this way: iTextSharp.text.Image img = null; .......................................... .......................................... .......................................... if (currentVuln.UrgencyRating > 0) { img = ChartHelper.GetPdfChartV2((int)currentVuln

fill pdf form with unicode characters

扶醉桌前 提交于 2019-12-01 05:06:55
I am trying to insert some unicode charaters (arabic) to PDF form with c# I used iTextSharp library but when I insert the characters and save characters in the PDF file the unicode characters not getting displayed until I double click on the position of the chracters that should be appeared. string pdfTemplate = @"c:\po.pdf"; string newFile = @"g:\test\completed_fw4.pdf"; PdfReader pdfReader = new PdfReader(pdfTemplate); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create)); AcroFields pdfFormFields = pdfStamper.AcroFields; pdfFormFields.SetField("position