itextsharp

iTextSharp ColumnText.SetSimpleColumn Addtext causes Error in Adobe Reader X 10.1.5

﹥>﹥吖頭↗ 提交于 2019-12-02 12:40:15
问题 The code below illustrates a problem I have with iTextSharp. Everything works perfectly. The pdf file is created and appears correct on the screen. When I print the pdf from Adobe Reader X, it looks exactly right but Adobe reports "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem." Unfortunately, the file has to be attached to an email and sent to clients. The error message is not a good

Draw a rectangle at the *current position* and then get its position coordinates

柔情痞子 提交于 2019-12-02 12:24:38
So, I am writing some text into a PDF file using iTextSharp. After having added a few paragraphs and phrases to the PDF document, I want to: Draw the next piece of text on top of a rectangle that has a fill color, say, red. I can compute the required width and height that the rectangle must have based on the text metrics of the text I am going to write on top of it. But how do I tell the Rectangle API what is top and left coordinates are, as in where it must be drawn? Seems that you are looking for the Chunk.setBackground() method. This draws a colored background underneath some text. There's

consolidate the fonts between merges pdfs itextsharp C#

北战南征 提交于 2019-12-02 11:43:04
问题 I need to merge multiple pdfs together. I am using itextsharp to create all the pdfs. I need to reduce the size of the pdfs to the lowest possible size. I know the fonts are being duplicated for each pdf. Is there to use only one set of fonts throughout the merged pdf? For example, pdf1 is 2.8mb and pdf2 is 2.8 mb I merge them together and its about 5.7mb. I know for a fact that both of those pdfs are using the same font but the data for the font is being duclpicated even though its in the

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

折月煮酒 提交于 2019-12-02 11:22: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.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText))); / / ... } You use the

How to convert pdf file to excel in c#

99封情书 提交于 2019-12-02 11:09:49
I want to extract some data like " email addresses " .. from table which are in PDF file and use this email addresses which I extract to send email to those people. What I have found so far through searching the web: I have to convert the PDF file to Excel to read the data easily and use them as I want. I find some free dll like itextsharp or PDFsharp . But I didn't find any snippet code help to do this in C#. is there any solution ? You absolutely do not have to convert PDF to Excel. First of all, please determine whether your PDF contains textual data, or it is scanned image. If it contains

crop Left side of pdf using Itextsharp

泄露秘密 提交于 2019-12-02 11:09:39
I am trying to crop left side of pdf to 10 mm. i used below code public void TrimLeft(string sourceFilePath, string outputFilePath) { PdfReader pdfReader = new PdfReader(sourceFilePath); float width =(float) GetPDFwidth(sourceFilePath); float height = (float)GetPDFHeight(sourceFilePath); float widthTo_Trim = iTextSharp.text.Utilities.MillimetersToPoints(10); // Set which part of the source document will be copied. // PdfRectangel(bottom-left-x, bottom-left-y, upper-right-x, upper-right-y) PdfRectangle rect = new PdfRectangle(0, 0, width - widthTo_Trim, height); PdfRectangle rectLeftside = new

ItextSharp with PowerShell Merging Tiff and PDF to 1 large PDF

主宰稳场 提交于 2019-12-02 11:06:34
问题 I'm trying to write a powershell script that will loop through a csv file looking for Tiff & PDF files using ItextSharp dll. The desired end result is every image and page of a pdf needs to be in one large pdf. My thoughts are to create two functions to accomplish this. 1 for images and the other for PDF's. The image function is working properly, but the pdf is throwing a error: Exception calling ".ctor" with "1" argument(s): " not found as file or resource." Any thoughts on fixing add-pdf

iTextSharp is not showing HTML table in PDF

心不动则不痛 提交于 2019-12-02 10:59:34
问题 I don't understand why it is not working. Here is my code: Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); string htmlstr = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p><table border=1><tr><td>1st</td><td>2nd</td></tr><tr><td>3rd</td><td>4th</td></tr></table></body><

Cannot get CSS to work in iTextSharp (5.4.3) when making pdf

喜欢而已 提交于 2019-12-02 10:59:05
问题 I have a problem trying to apply a css file to my pdf using the iTextSharp (5.4.3) generation library. basically the css is not being applied at all. I have the following method in my vb.net file Protected Sub btnPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPreview.Click Dim bytes As Byte() bytes = System.Text.Encoding.UTF8.GetBytes(letterRadEdit.Content) Dim tagProcessor As tool.xml.html.DefaultTagProcessorFactory() Using input As New MemoryStream(bytes,

save Pdf File in the particular folder instead of downloading

天大地大妈咪最大 提交于 2019-12-02 10:55:13
I am doing html to pdf file . Its Downloading instantly . I dont want download instantly. i want to save the file in my project folder once converted. My C# Code string html ="<table><tr><td>some contents</td></tr></table>"; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=WelcomeLetter.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); StringReader sr = new StringReader(table); Document ResultPDF = new Document(iTextSharp.text.PageSize.A4, 25,