itextsharp

ITextSharp Parsing HTML with Images in it: It parses correctly but wont show images

落爺英雄遲暮 提交于 2019-11-29 13:33:27
问题 I am trying to generate a .pdf from html using the library ITextSharp. I am able to create the pdf with the html text converted to pdf text/paragraphs My Problem: The pdf does not show my images(my img elements from the html). All my img html elements in my html dont get displayed in the pdf? Is it possible for ITextSharp to parse HTML & display images. I really hope so otherwise I am stuffed :( I am linking to the correct directory where the images are(using IMG_BASURL) but they are just not

How to Get PDF page width and Height?

余生长醉 提交于 2019-11-29 13:27:50
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); 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 cropbox = reader.GetCropBox(page); Most of them return an object of type Rectangle that has methods such as

Image alignment in text?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 13:14:26
Using iTextSharp i'm trying to align an image so that it gets embedded in a paragraph. I can do it like this: iTextSharp.text.Image image; image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP; document.Add(image); document.Add(new Paragraph("Large string of text goes here")); But the image comes out on the top right with the text surrounding it (kind of like an L) What I want is the text to be a few paragraphs then the image with text below it (kind of like a C). Does anyone know how I would do this VIA iTextSharp? Edit: I also tried iTextSharp.text.Image image; image.Alignment = Image.ALIGN

Centered, multiline text using iTextSharp ColumnText

你离开我真会死。 提交于 2019-11-29 12:35:01
I am trying to center a block of multiline text using iTextSharp. I thought that using the ColumnText would do the trick, but I'm having some trouble getting both center alignment, as well as proper wrapping working at the same time. Here is some code which shows the 2 methods I'm trying: private void PrintLocationAddress(PdfContentByte Canvas, string Address) { //define the regions for our ColumnText objects Rectangle rect1 = new Rectangle(150f, 300, 350f, 450f); Rectangle rect2 = new Rectangle(150f, 50f, 350f, 200f); //outline the rectangles so we can visualize placement of the ColumnText

problem in drawing a line in a pdf file using itextsharp

本秂侑毒 提交于 2019-11-29 12:32:36
问题 I am generating a pdf file in asp.net c# using itextsharp. i am not able to draw a horizontal line/verticle line/dotted line. i tried to draw a line using the following code,i am getting no errors but the line is also not getting displayed in the pdf file PdfContentByte cb = wri.DirectContent; cb.SetLineWidth(2.0f); // Make a bit thicker than 1.0 default cb.MoveTo(20, pdfDocument.Top - 40f); cb.LineTo(400, pdfDocument.Top - 40f); cb.Stroke(); What is the problem in the code.Is it because of

Print PDF Created using itextsharp

こ雲淡風輕ζ 提交于 2019-11-29 12:30:21
My Goal is to print a RDLC report on the client machine without preview. I can not use the ReportViewer print button since it requires the installation of ActiveX object and there are no permissions for that. So, I'm using ITextSharp to create a PDF from the byte array returned from the rendered LocalReport, and add a JavaScript for print. During Debug, I can see that the PDF is generated and has 2 pages, and everything looks OK. I don't receive any errors and the function exits OK, but it doesn't print. What am I doing wrong, or what am I missing? This is my code: string jsPrint = "var pp =

underline portion of text using iTextSharp

廉价感情. 提交于 2019-11-29 12:26:53
I have an application that uses itextsharp to fill PDF form fields. One of these fields has some text with tags. For example: <U>This text should be underlined</>. I'd like that the text closed in .. has to be underlined. How could I do that? How could I approch it with HTMLWorker for example? Here's the portion of code where I write my description: for (int i = 0; i < linesDescription.Count; i++) { int count = linesDescription[i].Count(); int countTrim = linesDescription[i].Trim().Count(); Chunk cnk = new Chunk(linesDescription[i] + GeneralPurpose.ReturnChar, TextStyle); if (firstOpe && i >

iText – HTML to PDF - Image is not displayed in PDF

会有一股神秘感。 提交于 2019-11-29 11:48:21
问题 I have a html page with text, image and I am parsing the HTML content to iText to generate the PDF. In the generated PDF,Included images are not getting displayed and , only the text is getting displayed. If I pass the absolute path like D:/Deiva/CRs/HTMLPage/article-101-horz.jpg then the image will get printed. But if I try to print the image from the server like http://localhost:8085/content/dam/article-101-h1.jpg or http://www.google.co.in/intl/en_ALL/images/logos/images_logo_lg.gif then

ITextSharp returning same size pdf when I'm trying to compress pdf file with different levels

谁都会走 提交于 2019-11-29 11:42:49
I'm reading a pdf and injecting some content using itextsharp. The resulting byte[] is passed to the method below along with the compression level. public static byte[] method(byte[] pdf,int compressionlevel) { using (MemoryStream outputPdfStream1 = new MemoryStream()) { //PdfReader reader1 = new PdfReader(pdf); //PdfStamper stamper1 = new PdfStamper(reader1, outputPdfStream1); //int level = (int)compressionlevel; //if (level <= 9) // stamper1.Writer.CompressionLevel = (int)compressionlevel; //else // stamper1.Writer.SetFullCompression(); //stamper1.SetFullCompression(); //stamper1.Close(); /

Save pdf file with user input filename (iTextSharp)

断了今生、忘了曾经 提交于 2019-11-29 11:29:25
I want to allow user to enter his own file name, just like save file dialog and stream (Example: Stream s = File.Open(sfdPdf.FileName, FileMode.CreateNew) Here is my code: private void btnSave_Click(object sender, EventArgs e) { System.Drawing.Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); } bitmap.Save("Image.jpeg", ImageFormat.Jpeg); } Document doc = new Document(PageSize.LETTER, bounds.Left, bounds