itextsharp

How can I restrict the width of a paragraph on a PDF page using iTextSharp?

大兔子大兔子 提交于 2019-12-11 22:09:18
问题 I want to insert a paragraph (which will word-wrap over several lines) into a PDF document using iTextSharp, but I want to restrict the width of the paragraph to the left half of the page. I see no "width" property for the Paragraph class, but surely there is a way to do this, stimmt? UPDATE The supposed answer doesn't work for me because it uses iText (Java) stuff apparently unavailable in iTextSharp (C#). Specifically (to begin with, there might be more): ct.setSimpleColumn(myText, 60, 750,

C# iTextSharp Extracted CMYK images returns in RGB Format

旧街凉风 提交于 2019-12-11 21:14:42
问题 I am using iTextsharp to extracted images from epaper PDF files, the images in the PDF files are in CMYK format, but the extracted images are in RGB. Please advice on this. Thanks in advance int xrefIdx = ((PRIndirectReference)obj).Number; PdfObject pdfObj = doc.GetPdfObject(xrefIdx); PdfStream str = (PdfStream)pdfObj; byte[] bytes = PdfReader.GetStreamBytesRaw((PRStream)str); using (System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes)) { var rawImage = System.Drawing.Image

iText C# Read pdf for regular expression match, extract only those pages to new pdf

一笑奈何 提交于 2019-12-11 20:54:21
问题 I'm having an issue reading an existing pdf for regular expression matches, then extracting those pages to a new pdf. I've run into some issues with this as a whole. I've decided to clear my head and start again from scratch. I'm able to take a 3 page pdf and extract the pages individually into a new file using this code: static void Main(string[] args) { string srcFile = @"C:\Users\steve\Desktop\original.pdf"; string dstFile = @"C:\Users\steve\Desktop\result.pdf"; PdfReader reader = new

How can I pass an Excel created with XML to PDF MVC

a 夏天 提交于 2019-12-11 20:26:53
问题 I need to create a PDF from an Excel created with XML. My application is based on MVC 4.0. Searching I found ITextSharp but I can't find examples of code or something like that. How can I export to PDF from Excel using ITextSharp? 回答1: First, separate the program from the file format and the API. Excel is a desktop spreadsheet program. XLS and XLSX are binary file formats for storing spreadsheet information. Open XML is a broad subject but usually refers to either the zipped XML file format

Unable to Set Font Family in iTextSharp XMLWorker

回眸只為那壹抹淺笑 提交于 2019-12-11 20:23:10
问题 I am trying to parse some HTML to PDF using itextsharp XMLWorker library. It is working fine but I am unable to render some Unicode characters (Turkish) into my pdf. I have read several blogs about the problem and they all propose registering a font which supports unicode characters. Then in external css file, I need to specify the font family to use. html { font-family: 'Arial Unicode MS'; } I also tried all Arial as family too. I tried setting the family in html as well. <body face = 'Arial

While extracting text from PDF file using iTextSharp, I am getting this error: “Could not find image data or EI”

*爱你&永不变心* 提交于 2019-12-11 20:22:38
问题 While extracting text from PDF file using iTextSharp, I am getting this error: "Could not find image data or EI" This error occurs on particular pages that contains image only. Could the reason be because I am trying to extract the text without checking whether there is any text content in the page? 回答1: Inline images are not specified very well in the PDF specification. The image data should be contained between ID and EI operators. But there's a possibility the image data itself contains

Mixing text and images causes incorrect vertical positioning

夙愿已清 提交于 2019-12-11 20:21:38
问题 Using iTextSharp version 5.5.8 (same bug existed in 5.5.7), there's an unpleasant bug when you add images to Chapters and Sections - the images and the section headings start out OK but quickly become offset relative to each other. The PDF generated from the following code starts out correctly, it says "Section 1" and below it is the image. The next section ("Section 2") has a little of the image overlapping the section text, the next section is even worse, etc. I think it's the text that's

Determine what user account iTextSharp runs as

夙愿已清 提交于 2019-12-11 20:14:00
问题 I have a website where users can upload PDF files and I then parse them using iTextSharp. The uploaded files are saved to a network share without a problem. I then pass the file path of the newly saved file to iTextSharp: pdfReader = new PdfReader(fileName); But I get: Error: \\networkshare\savedPDF.pdf not found as file or resource. File: \\networkshare\savedPDF.pdf Looking at the source code I see that it was not able to get the file stream: inp = BaseFont.GetResourceStream(filePath); if

iTextSharp generating pdfs, compiles and runs without error but no PDF appears

拟墨画扇 提交于 2019-12-11 20:01:38
问题 I've tried a number of different variations to output a very basic PDF from memory but all seem to return the same result, which is to say it doesn't actually return anything. The code compiles and runs without error but when VS finishes processing the code nothing happens. I'm using VS2008 and iTextSharp v5.1.1 Does anyone have any suggestions please? Here is my code in its current state: MemoryStream ms = new MemoryStream(); Document doc = new Document(); PdfWriter writer = PdfWriter

iTextSharp - update PDF catalog in SharePoint Document Library

≡放荡痞女 提交于 2019-12-11 19:49:52
问题 I'm trying to store and update a string in the PDF file catalog using the iTextSharp library. I'm able to do this without issue in a standard desktop application but I'm unable to get it to save on a SharePoint server (As part of a SharePoint feature which is written in C#). I have an SPFile which is a recently added PDF file in the SharePoint Document Library. I'm able to read an existing catalog property out of the file by using reader = new PdfReader(File.OpenBinaryStream()); PdfName name