itextsharp

Converting images to PDF with iTextSharp preserve clipping path

江枫思渺然 提交于 2019-12-01 12:57:01
We're looking to convert images in bulk to PDF, programmatically. So far it looks like we will be using iTextSharp but we have an issue with JPG images with clipping path. We are using the following code in our tests: using (FileStream fs = new FileStream(output, FileMode.Create, FileAccess.Write, FileShare.None)) { using (Document doc = new Document()) { using (PdfWriter writer = PdfWriter.GetInstance(doc, fs)) { doc.Open(); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(source); image.SetAbsolutePosition(0, 0); doc.SetPageSize(new iTextSharp.text.Rectangle(0, 0, image.Width,

Inputting image data to PDF with iText

▼魔方 西西 提交于 2019-12-01 12:50:56
I have an ImageButton in my website that has a dynamic source well it basically looks like this: "data:image/svg+xml;base64,...." So I am trying to insert an image in to PDF using that. This is the code I use iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(new Uri(((ImageButton) FindControl(fieldKey)).ImageUrl)); I either get a "The URI is empty" error or a path not found. Any ideas how to approach this? I doubt anyone would google this but I figured it out so why not post an anwser. To implement data img types in to PDF remove the prefix part and then convert it back from base

itextsharp PdfCopy and landscape pages

房东的猫 提交于 2019-12-01 12:37:20
I'm using itextsharp to join mutiple pdf documents and add a footer. My code works fine - except for landscape pages - it isn't detecting the page rotation - the footer is not centerd for landscape: public static int AddPagesFromStream(Document document, PdfCopy pdfCopy, Stream m, bool addFooter, int detailPages, string footer, int footerPageNumOffset, int numPages, string pageLangString, string printLangString) { CreateFont(); try { m.Seek(0, SeekOrigin.Begin); var reader = new PdfReader(m); // get page count var pdfPages = reader.NumberOfPages; var i = 0; // add pages while (i < pdfPages) {

Determine properties such as if PDF is Simplex or Duplex in iTextSharp

不羁岁月 提交于 2019-12-01 12:36:00
问题 I am using iTextSharp for reading and managing PDF documents. Things such as stamping overlays for the background or logos and backers. The PDF's are statement files, so I cannot give an example. I am wondering how to view the settings of the PDF to see if the PDF file is Simplex or Duplex, and that sort of information. Any help or suggestions would be appreciated. At the moment I test for certain criteria of second page, and this is a poor and bad way to do this. Thanks in advance, and happy

iTextSharp PDF Reading highlighed text (highlight annotations) using C#

孤人 提交于 2019-12-01 12:02:12
问题 I am developing a C# winform application that converts the pdf contents to text. All the required contents are extracted except the content found in highlighted text of the pdf. Please help to get the working sample to extract the highlighted text found in pdf. I am using the iTextSharp.dll in the project 回答1: Assuming that you're talking about Comments. Please try this: for (int i = pageFrom; i <= pageTo; i++) { PdfDictionary page = reader.GetPageN(i); PdfArray annots = page.GetAsArray

get original content of a pdf signed with itextsharp

别来无恙 提交于 2019-12-01 12:00:51
I'm trying to get the original document of a signed PDF in order to compare it's hash with an stored doc. This is really easy when the document has several signatures, with acrobat reader you can go the previous revision of the document save it and that's it. Surprisingly this does not work with the first signature, where there is no straight forward way to get the original data. As it is not possible to do it with the reader I have tried programatically with iTextSharp. However although I have googled deeply I have not found how to do it. The only relevant post I found is this one but no

Inputting image data to PDF with iText

早过忘川 提交于 2019-12-01 11:59:15
问题 I have an ImageButton in my website that has a dynamic source well it basically looks like this: "data:image/svg+xml;base64,...." So I am trying to insert an image in to PDF using that. This is the code I use iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(new Uri(((ImageButton) FindControl(fieldKey)).ImageUrl)); I either get a "The URI is empty" error or a path not found. Any ideas how to approach this? 回答1: I doubt anyone would google this but I figured it out so why not

Remove hyperlinks from a PDF document (iTextSharp)

假如想象 提交于 2019-12-01 11:45:25
I'm trying to leverage iTextSharp (very new to the product) to remove hyperlinks from a PDF document. Does anyone know if this is possible? I've been digging through the API and haven't found an obvious way to do this. My problem is that I'm doing maintenance on a system that has PDFs empbedded in an iframe and the links within the PDF are causing users to end up browsing the site within the iframe rather than in a new window or tab so I'm looking for a way to kill the links in the PDF at request time. Thanks in advance, Scott The links people click on are annotations in a given page's /Annots

itextsharp PdfCopy and landscape pages

与世无争的帅哥 提交于 2019-12-01 11:26:17
问题 I'm using itextsharp to join mutiple pdf documents and add a footer. My code works fine - except for landscape pages - it isn't detecting the page rotation - the footer is not centerd for landscape: public static int AddPagesFromStream(Document document, PdfCopy pdfCopy, Stream m, bool addFooter, int detailPages, string footer, int footerPageNumOffset, int numPages, string pageLangString, string printLangString) { CreateFont(); try { m.Seek(0, SeekOrigin.Begin); var reader = new PdfReader(m);

itextsharp add text over a circle image in a table cell

孤人 提交于 2019-12-01 11:25:51
I need to have a table with multiple columns where I have different coloured circles in different cells with a number in the middle of the circle. Similar to the mockup below but with everything centralized and equal. I have tried the following: PdfContentByte canvas = writer.DirectContent; PdfTemplate template = canvas.CreateTemplate(40, 40); template.SetLineWidth(1f); template.Circle(15f, 15f, 15); template.Stroke(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(template); img.Alignment = iTextSharp.text.Image.UNDERLYING | iTextSharp.text.Image.ALIGN_CENTER; Phrase imgPhrase