itextsharp

itextsharp adding header and footer, displayed inside the page margin not outside the page margin.

笑着哭i 提交于 2019-12-02 16:36:57
问题 I am new to ItextSharp, just wondering how to place header and footer outside the margin after end of page event? it seems when i used the onendpage event instead of adding the footer outside of the page margin, it adds inside of page margin, and it always produce stackoverflow exception when it will be over the bottom margin where it should add outside of the margin? are there any settings to tell to add the text in document footer outside of margin (or is it padding)? thanks in advance. 回答1

iTextSharp: Page header out of alignment with large tables

纵饮孤独 提交于 2019-12-02 15:41:03
问题 I am using the latest version of iTextSharp (5.4.3). When defining an even simple page header the header gets out of vertical alignment if the document contains large tables that do not fit on one page. The alignment on the first page a large table is displayed is fine, but on subsequent pages the header is displayed further down and overlays the table. My code is below. Would be nice to get a workaround or an idea what could be wrong. By the way: When adding paragraphs that cause an

Maintain similar image size in PDF using itextsharp

冷暖自知 提交于 2019-12-02 14:27:47
问题 i'm using itextsharp to bring my picture over to the pdf file. I uses chunk. However when i uses the chunk new line, my image changes it size despite me putting the same scaletofit. protected void btnPDF_Click(object sender, EventArgs e) { var doc1 = new Document(); var filename = "MyTestPDF" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".pdf"; var output = new FileStream(Path.Combine("C:\\Users\\apr13mpsip\\Downloads", filename), FileMode.Create); iTextSharp.text.pdf.PdfWriter.GetInstance

ITEXTSHARP in .net, Extract image code, I can't get this to work

一个人想着一个人 提交于 2019-12-02 13:53:45
问题 I am looking to simply extract all images from a pdf. I found some code that looks like it is exactly what I need Private Sub getAllImages(ByVal dict As pdf.PdfDictionary, ByVal images As List(Of Byte()), ByVal doc As pdf.PdfReader) Dim res As pdf.PdfDictionary = CType(pdf.PdfReader.GetPdfObject(dict.Get(pdf.PdfName.RESOURCES)), pdf.PdfDictionary) Dim xobj As pdf.PdfDictionary = CType(pdf.PdfReader.GetPdfObject(res.Get(pdf.PdfName.XOBJECT)), pdf.PdfDictionary) If xobj IsNot Nothing Then For

C# iTextSharp - Code overwriting instead of appending pages

痴心易碎 提交于 2019-12-02 13:51:59
问题 I've seen many posts that have helped me get to where I am, I'm new to programming. My intention is to get the files within the directory "sourceDir" and look for a Regex Match. When it finds a Match, I want to create a new file with the Match as the name. If the code finds another file with the same Match (the file already exists) then create a new page within that document. Right now the code works, however instead of adding a new page, it overwrites the first page of the document. NOTE:

ItextSharp - Acrofields are empty

隐身守侯 提交于 2019-12-02 13:40:21
问题 I have a PDF form with filled out fields. If I try to read the acrofields they are empty. But in the PDF I can change the values and save them. private static string GetFormFieldNamesWithValues(PdfReader pdfReader) { return string.Join("\r\n", pdfReader.AcroFields.Fields .Select(x => x.Key + "=" + pdfReader.AcroFields.GetField(x.Key)) .ToArray()); } var reader = new PdfReader((DataContext as PDFContext).Datei); AcroFields form = reader.AcroFields; txt.Text = GetFormFieldNamesWithValues(reader

Issue when trying to remove inline images from PDF with iTextSharp

*爱你&永不变心* 提交于 2019-12-02 13:31:12
I recently discovered iTextSharp. I was investigating a performance issue with the rendering of PDF documents and Bruno Lowagie (author of iText) kindly explained to me the reason why I was experiencing such an issue : it was due to the amount of "Inline Images" in my PDF documents. He also explained the basics to remove those "Inline Images"... (My purpose is to "possibly" show a preview of the document with a clear notice that it's not the actual document and that this one could be very slow to open. I clearly understand that what I am trying to do is far from robust/safe/... The problem

Shrinking the contents of a pdf page

眉间皱痕 提交于 2019-12-02 13:19:23
For my current project, I am required to take a pdf and shrink the contents of the first page without changing the overall size of the page so that I can add additional information to the bottom without it overlapping with any pre-existing content. Is there a way to do this using iTextSharp? I would appreciate any help you can give! You can shrink the content of a page by prepending a transformation matrix to that effect to the page content stream(s), e.g. like this: public void shrink(PdfStamper stamper, int page, float factor) { Rectangle crop = stamper.Reader.GetCropBox(page); float diffX =

crop Left side of pdf using Itextsharp

折月煮酒 提交于 2019-12-02 13:16:45
问题 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)

How to set monospaced font by using iTextSharp?

筅森魡賤 提交于 2019-12-02 12:48:13
This is how I managed my font so far: BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED, false); Font titleFont = new Font(bf, 20); Now, I want to set monospaced (fixed width) font for purpose of string formatting. Do I have to download some ttf file (as I was reading about it) or there is monospaced font already included in iTextSharp If you don't want to embed a font, you can use this: BaseFont bf = BaseFont.createFont( BaseFont.COURIER, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); Font titleFont = new Font(bf, 20); Helvetica is a proportional font. If you