itextsharp

Alter PDF - Text repositioning

烂漫一生 提交于 2019-12-30 10:04:16
问题 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

Replace multiple different images on one PDF template page with itext (itextsharp)

徘徊边缘 提交于 2019-12-30 07:25:11
问题 We have an ASP.NET application that users use to generate certain reports. So far we had one PDF template that had one image on it, and we would just replace that image with our programatically generated one (graph). We have used code from this site for that:http://blog.rubypdf.com/2007/12/12/how-to-replace-images-in-a-pdf/ Problem now is that we have two different images on one PDF page, and the code from link above selects both images on one page and replaces them all at once with our

MVC3 return multiple pdfs as a zip file

拟墨画扇 提交于 2019-12-30 03:33:23
问题 I have a view that returns a pdf (using iTextSharp) with multiple pages, but now I have to change it so that each page is a separate pdf (with it's own unique title) and return a zip file. My original code looks like this: public FileStreamResult DownloadPDF() { MemoryStream workStream = new MemoryStream(); Document document = new Document(); PdfWriter.GetInstance(document, workStream).CloseStream = false; document.Open(); // Populate pdf items document.Close(); byte[] byteInfo = workStream

Multipage PDF document from predefined template

天大地大妈咪最大 提交于 2019-12-30 00:48:07
问题 I have a requirement to generate invoice reports in PDF using some predefined company templates. I am able to create/generate SINGLE PAGE PDF reports using iTextSharp. Problem: The problem comes when the invoice statement spans MULTIPLE PAGES . I am not able to extend the report(invoice statement) to next(2nd) page. If all the data can not be accommodated on one page it should be written on 2nd page, while still using the company template. The template is present at following path:

Add alternative text for an image in tagged pdf (PDF/UA) using iText

蹲街弑〆低调 提交于 2019-12-29 09:09:36
问题 I've looked up some documentations and examples under the http://developers.itextpdf.com/examples. I know iText is able to generate tagged pdf from scratch, but is it possible to insert alternative text to images in an existing tagged pdf (without changing anything else)? I need to implement this feature in a program without using GUI applications (such as Adobe Acrobat Pro). Thanks. 回答1: Please take a look at the AddAltTags example. In this example, we take a PDF with images of a fox and a

How to Get PDF page width and Height?

我的梦境 提交于 2019-12-29 08:32:14
问题 I have a pdf , and I want to get the width and Height for each page in pdf using iTextSharp? given this is the pdf I want to work with string source=@"D:\pdf\test.pdf"; PdfReader reader = new PdfReader(source); 回答1: Do you want the MediaBox? Rectangle mediabox = reader.GetPageSize(page); Do you want the rotation? int rotation = reader.GetPageRotation(page); Do you want the combination of both? Rectangle pagesize = reader.GetPageSizeWithRotation(page); Do you want the CropBox? Rectangle

How to write in a specific location the zapfdingbatslist in a pdf document using iTextSharp

删除回忆录丶 提交于 2019-12-29 08:23:09
问题 I want to put a check mark using zapfdingbatslist on my pdf document in iTextSharp in a specific location . What I could do so far is I could show the check mark but it's all on the side of the document and not on a specific X, Y coordinate that I want it to be. I have a code below that would hopefully give you the idea of what I am talking about. String outputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.pdf"); System.IO.FileStream fs; Document doc =

iTextSharp GetFieldPositions to SetSimpleColumn

牧云@^-^@ 提交于 2019-12-29 08:13:00
问题 I'm using the latest version of iTextSharp found here: http://sourceforge.net/projects/itextsharp/ I am trying to use ColumnText.SetSimpleColumn after getting the position of some AcroFields using GetFieldPositions( fieldName ). All the examples I can find show GetFieldPositions returning a float[] however this doesn't appear to be the case anymore. It now appears to be returning IList which doesn't (according to Visual Studio) implicitly convert to a float[]. Inside the return value at the 0

Horizontal text alignment in a PdfPCell

帅比萌擦擦* 提交于 2019-12-29 07:32:11
问题 I am using this code to align horizontally. cell = New PdfPCell(); p = New Phrase("value"); cell.AddElement(p); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //Tried with Element.Align_Center Also. Tried Adding this line before adding element also. table.AddCell(cell); It's not working. I am creating a table with 5 columns in it and adding cells dynamically in runtime in a for loop with above code. I want all cells content to be centered. 回答1: I tried all the above solutions and none

Extract Image from a particular page in PDF

给你一囗甜甜゛ 提交于 2019-12-29 07:09:15
问题 I want to extract an Image from a PDF file. I tried with the following code and it extracted a jpeg Image perfectly from the PDF. The problem is how to extract image from a particular page e.g. Page 1 or from some other page. I don't want to read the whole PDF to search for the Image. Any suggestions? Code to extract Image: private void List<System.Drawing.Image> ExtractImages(String PDFSourcePath) { List<System.Drawing.Image> ImgList = new List<System.Drawing.Image>(); iTextSharp.text.pdf