itextsharp

iTextSharp table.SpacingBefore not working

∥☆過路亽.° 提交于 2019-12-10 13:45:57
问题 I have a table which I'm trying to space down about 20/30 floating points (f) from the top margin of a pdf document. The reason I want to space down a bit is because I have a rectangle border running around the margin of my pdf document. PdfPTable table = new PdfPTable(1); table.SpacingBefore = 20f; table.SpacingAfter = 20f; table.TotalWidth = 700f; table.LockedWidth = true; table.SpacingAfter works perfectly well but table.SpacingBefore will not, my table just sits at the top margin and will

itextsharp: how to show the bottom line of a table with property HeaderRows=1 if border bottom of the row is not set?

*爱你&永不变心* 提交于 2019-12-10 13:25:23
问题 I use the last version of itextsharp. I use the property HeaderRows=1 so that if there is a pagebreak, the Header rows will appear again in the next page. Then we have the rows of the content with the border style without bottomline like this: PdfPCell cell1 = null; cell1 = new PdfPCell(new Phrase(string.Format("{0}", c1), fn)); cell1.Border = Rectangle.RIGHT_BORDER | Rectangle.LEFT_BORDER; When there is a pagebreak, the line bottom of the table is not shown, which is not logical. Even if the

delete first page from PDF using iTextSharp

做~自己de王妃 提交于 2019-12-10 13:22:57
问题 Is there a way we can delete the first page of the PDF using iTextSharp? 回答1: There's no direct way to remove pages from a PDF using iTextSharp. However, you can copy all the pages you want from a PDF and skip the pages you don't want. In your case you'd copy out all but the first page. I wrote a method that does this based on the code I found on this blog entry. 回答2: PdfReader reader_SecondPdf = new PdfReader(pdf_of_Second_File); for (j = 2; j <= reader_SecondPdf.NumberOfPages; j++) { } 回答3:

Error in converting HTML with images to PDF using itextsharp

夙愿已清 提交于 2019-12-10 11:56:31
问题 In my application first am allowing the user to create html document using CKEDITOR where user can can create html document and can insert image, form fields etc. the generated HTML document is than converted into PDF. If HTML document contains plain text than PDF file gets created successfully but if user inserts image in it than gives error. code for creating PDF document. public ActionResult CreateFile(FormCollection data) { var filename = data["filename"]; var htmlContent = data["content"

Merge PDFs iTextSharp

别等时光非礼了梦想. 提交于 2019-12-10 11:26:18
问题 I looked at a few examples online and came up with this code to merge pdfs using iTextSharp. But I am getting an error :. {"The document has no pages."} It fails at Page = writer.GetImportedPage(reader, X); Here is stack trace : at iTextSharp.text.pdf.PdfPages.WritePageTree() at iTextSharp.text.pdf.PdfWriter.Close() at iTextSharp.text.pdf.PdfCopy.Close() at iTextSharp.text.Document.Close() It has 3 pages when I debugged it. What is wrong here?? Here is my code public static MemoryStream

Generating QR Barcode using iTextSharp

故事扮演 提交于 2019-12-10 10:45:04
问题 I have an array of values say arr(0)="Sam" arr(1)="1452" arr(2)="NY" I want to generate a QR barcode with these values. We are using ITextSharp. Any help will be appreciated. Iam using vb.net. 回答1: Here are some examples how to create barcodes with iText: http://itextpdf.com/examples/iia.php?id=297 (the last one is a QR barcode) The datails of the API is here: http://api.itextpdf.com/itext/com/itextpdf/text/pdf/BarcodeQRCode.html Please note that even though these links refer to the Java

Create barcode with text image (not pdf) using itextsharp

橙三吉。 提交于 2019-12-10 10:44:42
问题 I am able to create barcode using itextsharp CreateDrawingImage method. But I want to include the actual text into the image. How do I do that? or How do I use CreateImageWithBarcode method to save as image (Jpeg/Png)? Thanks 回答1: Facing the same problem and after looking in iTextSharp sources it appears you can't. Besides with CreateDrawingImage() I had problems with image resizing, it was fuzzy and unreadable. I ended up using this library (very cool): http://www.codeproject.com/KB/graphics

Read localized PDF file using Itextsharp

99封情书 提交于 2019-12-10 10:16:45
问题 I am trying to read PDF file using iTextSharp. The issue is when trying to read a PDF file other than English (Hindi or Arabic for example) it's not getting the correct words. I am wondering, should I install the Hindi or Arabic font on my system or do I need to do something with encoding? ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding

Using itextsharp to split a pdf into smaller pdf's based on size

你说的曾经没有我的故事 提交于 2019-12-10 07:03:20
问题 So we have some really inefficient code that splits a pdf into smaller chunks based on a maximum size allowed. Aka. if the max size is 10megs, an 8 meg file would be skipped, while a 16 meg file would be split based on the number of pages. This is code that I inherited and feel like there has got to be a more efficient way to do this that requiring only one method and less instantiation of objects. We use the following code to call the methods: List<int> splitPoints = null; List<byte[]>

How do I add a border to a page using iTextSharp?

冷暖自知 提交于 2019-12-10 03:37:51
问题 Is it possible to add a border to a page in a PDF document using iTextSharp ? I'm generating the PDF file from scratch, so I don't need to add borders to an already existing document. Here's my code for example: Document pdfDocument = new Document(PageSize.LETTER); Font headerFont = new Font(baseFont, 13); Font font = new Font(baseFont, 10); PdfWriter writer = PdfWriter.GetInstance(pdfDocument, new FileStream(fileName, FileMode.Create)); pdfDocument.Open(); //I add IElements here. pdfDocument