itextsharp

Adding an image to a PDF using iTextSharp and scale it properly

大兔子大兔子 提交于 2019-11-26 16:13:46
问题 here's my code. It correctly adds the pictures I want and everything works except that the images are using their native resolution, so if the image is big it's being cropped to fit the page. Is there some way to have the picture use like a Zoom feature to stretch to fit, but also maintain the aspect ratio? There has to be something I'm missing there. :P Here's a picture to illustrate the problem: using System; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; using System

Extracting image from PDF with /CCITTFaxDecode filter

耗尽温柔 提交于 2019-11-26 16:10:51
问题 I have a pdf that was generated from scanning software. The pdf has 1 TIFF image per page. I want to extract the TIFF image from each page. I am using iTextSharp and I have successfully found the images and can get back the raw bytes from the PdfReader.GetStreamBytesRaw method. The problem is, as many before me have discovered, iTextSharp does not contain a PdfReader.CCITTFaxDecode method. What else do I know? Even without iTextSharp I can open the pdf in notepad and find the streams with

How can I insert an image with iTextSharp in an existing PDF?

落花浮王杯 提交于 2019-11-26 16:05:48
I have an existing PDF and I can use FdFWriter to input to text boxes. It works well. Now I have an image. I have read the documentation and looked at many examples but they all create new documents and insert an image. I want to take an existing PDF and insert an image into either an image field or as the icon image of a button. I have tried but it corrupts the document. I need to be able to take an existing document and put an image on it. I do not want to open, read, replace, and delete the original. This original changes and the name "original" only means the source file in this context.

using ITextSharp to extract and update links in an existing PDF

ε祈祈猫儿з 提交于 2019-11-26 15:27:46
I need to post several (read: a lot) PDF files to the web but many of them have hard coded file:// links and links to non-public locations. I need to read through these PDFs and update the links to the proper locations. I've started writing an app using itextsharp to read through the directories and files, find the PDFs and iterate through each page. What I need to do next is find the links and then update the incorrect ones. string path = "c:\\html"; DirectoryInfo rootFolder = new DirectoryInfo(path); foreach (DirectoryInfo di in rootFolder.GetDirectories()) { // get pdf foreach (FileInfo pdf

Getting Coordinates of string using ITextExtractionStrategy and LocationTextExtractionStrategy in Itextsharp

跟風遠走 提交于 2019-11-26 15:23:21
I have a PDF file that i am reading into string using ITextExtractionStrategy.Now from the string i am taking a substring like My name is XYZ and need to get the rectangular coordinates of substring from the PDF file but not able to do it.On googling i got to know that LocationTextExtractionStrategy but not getting how to use this to get the coordinates. Here is the code.. ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding

iTextSharp 5 polish character

对着背影说爱祢 提交于 2019-11-26 14:44:34
问题 I have problem with polish character using itextSharp. I want to create pdf from html. Everything works fine but polish character are missing. I use function lower: private void createPDF(string html) { //MemoryStream msOutput = new MemoryStream(); TextReader reader = new StringReader(html);// step 1: creation of a document-object Document document = new Document(PageSize.A4, 30, 30, 30, 30); // step 2: // we create a writer that listens to the document // and directs a XML-stream to a file

How to align two paragraphs to the left and right on the same line?

人走茶凉 提交于 2019-11-26 14:27:49
问题 I want to display two pieces of content (it may a paragraph or text) to the left and right side on a single line. My output should be like Name:ABC date:2015-03-02 How can I do this? 回答1: Please take a look at the LeftRight example. It offers two different solutions for your problem: Solution 1: Use glue By glue, I mean a special Chunk that acts like a separator that separates two (or more) other Chunk objects: Chunk glue = new Chunk(new VerticalPositionMark()); Paragraph p = new Paragraph(

iTextSharp generated PDF: How to send the pdf to the client and add a prompt?

ε祈祈猫儿з 提交于 2019-11-26 14:25:32
问题 I have generated a pdf using iTextSharp, when its created it saves automatically in the location provided in my code on the server not on the client side and of course without telling anything to the user. I need to send it to the client and I need to prompt a dialogue box to ask the user where he wants to save his pdf.. how can i do this please? this is my pdf code: using (MemoryStream myMemoryStream = new MemoryStream()) { Document document = new Document(); PdfWriter PDFWriter = PdfWriter

Opening password-protected pdf file with iTextSharp

徘徊边缘 提交于 2019-11-26 14:15:59
问题 I'm making an application that should display PDFs with password. This is my code: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { string filePath = Request.QueryString["filePath"]; if (filePath.ToUpper().EndsWith("PDF")) { copyPDF(filePath); } } catch { string message = "<script language='Javascript'>alert('File Not Found! Call Records Department for verification. ')</script>"; ScriptManager.RegisterStartupScript(Page, this.GetType(), message, message,

iTextSharp Password Protected PDF

ぃ、小莉子 提交于 2019-11-26 13:46:12
问题 The following question and answer on StackOverflow show how to generate a PDF that cannot be opened without the appropriate password. Password protected PDF using C# I would like to use this framework similarly, but slightly altered to allow my users to "open" the PDF without needing the password, but only allow them to EDIT the PDF if they have the password. Is that possible with iTextSharp? if this matters, I am working in C# 4.0 within a WF 4.0 custom activity. 回答1: Yes, there are two