Search Results

Search found 123 results on 5 pages for 'itextsharp'.

Page 2/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • Can iTextSharp export to JPEG?

    - by SkippyFire
    I need to be able to export PDF's that I am creating to JPEG, so that users can have a screenshot/thumbnail of the end product, which is faster than opening the whole PDF. I am running this on an ASP.NET website running in Medium Trust in the Rackspace Mosso Cloud. I have yet to find a library that will either work in Medium trust, or in the case of ABC PDF, which works great locally, wont load in Mosso. Maybe Mosso has a custom trust level? I know that iTextSharp works on Mosso, but I haven't been able to figure how to "screenshot" a single page of a PDF, or export a page to JPEG. Is there anyone out there who has done this before?

    Read the article

  • iTextSharp Use Link Inside PdfPCell

    - by Baxter
    I am able to successfully put a link in the pdf with a friendly name: Anchor anchor = new Anchor("Google", linkFont); anchor.Reference = "https://www.google.com"; doc.Add(anchor); However, I cannot get get the anchor to work within a PdfPCell. Here is what I have tried so far: var memberCell = new PdfPCell(); Anchor anchor = new Anchor("Google", linkFont); anchor.Reference = "https://www.google.com"; memberCell.AddElement(new Anchor(anchor)); That displays the exception: System.ArgumentException: Element not allowed. I also tried: var memberCell = new PdfPCell(); Anchor anchor = new Anchor("Google", linkFont); anchor.Reference = "https://www.google.com"; memberCell.AddElement(new Phrase(anchor)); This does not throw an exception but it isn't a link it is just the word "Google". I am using the newest version of iTextSharp at this time v.(5.4.4.0) Any help on this would be greatly appreciated.

    Read the article

  • Need help with creating PDF from HTML using itextsharp

    - by Steven
    I'm trying to crate a PDF out of a HTML page. The CMS I'm using is EPiServer. This is my code so far: protected void Button1_Click(object sender, EventArgs e) { naaflib.pdfDocument(CurrentPage); } public static void pdfDocument(PageData pd) { //Extract data from Page (pd). string intro = pd["MainIntro"].ToString(); // Attribute string mainBody = pd["MainBody"].ToString(); // Attribute // makae ready HttpContext HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/pdf"; // Create PDF document Document pdfDocument = new Document(PageSize.A4, 80, 50, 30, 65); //PdfWriter pw = PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream); PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream); pdfDocument.Open(); pdfDocument.Add(new Paragraph(pd.PageName)); pdfDocument.Add(new Paragraph(intro)); pdfDocument.Add(new Paragraph(mainBody)); pdfDocument.Close(); HttpContext.Current.Response.End(); } This outputs the content of the article name, intro-text and main body. But it does not pars HTML which is in the article text and there is no layout. I've tried having a look at http://itextsharp.sourceforge.net/tutorial/index.html without becomming any wiser. Any pointers to the right direction is greatly appreciated :)

    Read the article

  • iTextSharp everything works but getting strange error when opening pdf document

    - by Dmitris
    Hello everybody, I am using iTextSharp to create my PDF document on the fly. Everything works fine, and i get no errors in the code; however, when i open created PDF it gives me error saying that document will be not displayed properly because it contain errors. Here is the code bellow that gives me a problem: public class pdfevents : PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document document) { base.OnEndPage(writer, document); PdfContentByte cb = writer.DirectContent; cb.BeginText(); cb.SetTextMatrix(20, document.GetBottom(-30)); BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.SetFontAndSize(bf, 10); //thats is the piece of code that makes problems //if i remove it then document displays without error cb.MoveTo(15F, document.GetBottom(-15)); cb.SetLineWidth(0.5F); cb.LineTo(document.GetRight(0), document.GetBottom(-15)); cb.Stroke(); cb.ShowText(DateTime.Now.ToLongDateString()); int n = writer.PageNumber; cb.SetTextMatrix(document.GetRight(20), document.GetBottom(-30)); cb.ShowText(" - " + n + " - "); cb.EndText(); } } If i remove following lines : //thats is the piece of code that makes problems //if i remove it then document displays without error cb.MoveTo(15F, document.GetBottom(-15)); cb.SetLineWidth(0.5F); cb.LineTo(document.GetRight(0), document.GetBottom(-15)); Then i am getting no error opening generated PDF, otherwise i can open PDF and see the document and it's content including the line. However, then i get error that document been generated with error. Can somebody tell me what is wrong ? Thanks in advance. cb.Stroke();

    Read the article

  • iTextSharp last version doesnot support metadata?

    - by zp chen
    Console.WriteLine("Chapter 1 example 6: Meta Information"); // step 1: creation of a document-object Document document = new Document(); try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.GetInstance(document, new FileStream("Chap0106.pdf", FileMode.Create)); // step 3: we add some metadata and open the document document.AddTitle("Hello World example"); document.AddSubject("This example explains step 6 in Chapter 1"); document.AddKeywords("Metadata, iText, step 6, tutorial"); document.AddCreator("My program using iText#"); document.AddAuthor("Bruno Lowagie"); document.AddHeader("Expires", "0"); document.Open(); // step 4: we add a paragraph to the document document.Add(new Paragraph("Hello World")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } // step 5: we close the document document.Close(); I am just copy the iTextSharp.tutorial. I get the pdf file Chap0106.pdf but metadata show nothing... I am use vs2008 xp system

    Read the article

  • iTextSharp table alignment

    - by Kumar
    I am using iTextSharp to create a pdf in my ASP.NET 3.5 application. Below is the current layout of my pdf: John Doe   EmployeeID 2008      Department1                                                        Department2                                                        Department3 Below is the code I am using: PdfPTable table = new PdfPTable(4); table.DefaultCell.Border = 0; var empName = new Phrase("John Doe"); var empIDHeading = new Phrase("EmployeeID"); var empID = new Phrase("2008"); var departments = new PdfPCell(CreateDepartments()) { Border = 0, NoWrap = true }; table.AddCell(empName); table.AddCell(empIDHeading ); table.AddCell(empID ); table.AddCell(departments); private PdfPTable CreateDepartments() { var d1 = new Phrase("Department1"); var d2 = new Phrase("Department2"); var d3 = new Phrase("Department3"); PdfPTable table = new PdfPTable(2); table.DefaultCell.Border = 0; table.AddCell(d1); table.AddCell(d2); table.AddCell(d3); return table; } How can I modify this code to get the below output:                                                        Department1                                                       Department2 John Doe   EmployeeID 2008      Department3

    Read the article

  • itextsharp PdfCopy and landscape pages

    - by Andreas Rehm
    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) { i++; // import page with pdfcopy var page = pdfCopy.GetImportedPage(reader, i); // get page center float posX; float posY; var rotation = page.BoundingBox.Rotation; if (rotation == 0 || rotation == 180) { posX = page.Width / 2; posY = 0; } else { posX = page.Height / 2; posY = 20f; } var ps = pdfCopy.CreatePageStamp(page); var cb = ps.GetOverContent(); // add footer cb.SetColorFill(BaseColor.WHITE); var gs1 = new PdfGState {FillOpacity = 0.8f}; cb.SetGState(gs1); cb.Rectangle(0, 0, document.PageSize.Width, 46f + posY); cb.Fill(); // Text cb.SetColorFill(BaseColor.BLACK); cb.SetFontAndSize(baseFont, 7); cb.BeginText(); // create text var pages = string.Format(pageLangString, i + footerPageNumOffset, numPages); cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, printLangString, posX, 40f + posY, 0f); cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, footer, posX, 28f + posY, 0f); cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, pages, posX, 20f + posY, 0f); cb.EndText(); ps.AlterContents(); // add page to new pdf pdfCopy.AddPage(page); } // close PdfReader reader.Close(); // return number of pages return i; } catch (Exception e) { Console.WriteLine(e); return 0; } } How do I detect the page rotation (e.g. landscape) format in this case? The given example works for PdfReader but not for PdfCopy. Edit: Why do I need PdfCopy? I tried copying a word pdf export. Some word hyperlinks will not work when you try to copy pages with PdfReader. Only PdfCopy transfers all needed page informations. Edit: (SOLVED) You need to use reader.GetPageRotation(i);

    Read the article

  • Creating PDF Documents with ASP.NET and iTextSharp

    The Portable Document Format (PDF) is a popular file format for documents. Due to their ubiquity and layout capabilities, it's not uncommon for a websites to use PDF technology. For example, an eCommerce store may offer a "printable receipt" option that, when selected, displays a PDF file within the browser. Last week's article, Filling in PDF Forms with ASP.NET and iTextSharp, looked at how to work with a special kind of PDF document, namely one that has one or more fields defined. A PDF document can contain various types of user interface elements, which are referred to as fields. For instance, there is a text field, a checkbox field, a combobox field, and more. Typically, the person viewing the PDF on her computer interacts with the document's fields; however, it is possible to enumerate and fill a PDF's fields programmatically, as we saw in last week's article. This article continues our investigation into iTextSharp, a .NET open source library for PDF generation, showing how to use iTextSharp to create PDF documents from scratch. We start with an example of how to programmatically define and piece together paragraphs, tables, and images into a single PDF file. Following that, we explore how to use iTextSharp's built-in capabilities to convert HTML into PDF. Read on to learn more! Read More >

    Read the article

  • iTextSharp: How to position and wrap long text?

    - by aximili
    The PDF I can produce at the moment: I want the text to fill up the space in the lower left. How can I do that? Thanks! This is my code: private static void CreatePdf4(string pdfFilename, string heading, string text, string[] photos, string emoticon) { Document document = new Document(PageSize.A4.Rotate(), 26, 36, 0, 0); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfFilename, FileMode.Create)); document.Open(); // Heading Paragraph pHeading = new Paragraph(new Chunk(heading, FontFactory.GetFont(FontFactory.HELVETICA, 54, Font.NORMAL))); document.Add(pHeading); // Photo 1 Image img1 = Image.GetInstance(HttpContext.Current.Server.MapPath("/uploads/photos/" + photos[0])); img1.ScaleAbsolute(350, 261); img1.SetAbsolutePosition(46, 220); img1.Alignment = Image.TEXTWRAP; document.Add(img1); // Photo 2 Image img2 = Image.GetInstance(HttpContext.Current.Server.MapPath("/uploads/photos/" + photos[1])); img2.ScaleAbsolute(350, 261); img2.SetAbsolutePosition(438, 220); img2.Alignment = Image.TEXTWRAP; document.Add(img2); // Text //Paragraph pText = new Paragraph(new Chunk(text, FontFactory.GetFont(FontFactory.HELVETICA, 18, Font.NORMAL))); //pText.SpacingBefore = 30; //pText.IndentationLeft = 20; //pText.IndentationRight = 366; //document.Add(pText); PdfContentByte cb = writer.DirectContent; cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, false), 18); cb.SetTextMatrix(46, 175); cb.ShowText(text); cb.EndText(); // Photo 3 Image img3 = Image.GetInstance(HttpContext.Current.Server.MapPath("/uploads/photos/" + photos[2])); img3.ScaleAbsolute(113, 153); img3.SetAbsolutePosition(556, 38); document.Add(img3); // Emoticon Image imgEmo = Image.GetInstance(HttpContext.Current.Server.MapPath("/Content/images/" + emoticon)); imgEmo.ScaleToFit(80, 80); imgEmo.SetAbsolutePosition(692, 70); document.Add(imgEmo); document.Close(); }

    Read the article

  • iTextSharp 5.0 Footer is not displaying

    - by Rick Make
    I am trying to create a simple footer that would display on the bottom of each page of the pdf document. I created a class that inherits from PdfPageEventHelper and it is set properly because the OnEndPage() method is called. But my temporary footer is not displaying. Is there something wrong that I am doing in my OnEndPage() method: public override void OnEndPage(PdfWriter writer, Document document) { base.OnEndPage(writer, document); int pageN = writer.PageNumber; String text = "Page " + pageN + " of "; float len = bf.GetWidthPoint(text, 8); Rectangle pageSize = document.PageSize; cb.SetRGBColorFill(100, 100, 100); cb.BeginText(); cb.SetFontAndSize(bf, 8); cb.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetBottom(30)); cb.ShowText(text); cb.EndText(); cb.AddTemplate(template, pageSize.GetLeft(40) + len, pageSize.GetBottom(30)); cb.BeginText(); cb.SetFontAndSize(bf, 8); cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "Printed On " + PrintTime.ToString(), pageSize.GetRight(40), pageSize.GetBottom(30), 0); cb.EndText(); }

    Read the article

  • iTextSharp HTMLWorker img not found 404

    - by David
    Hi, i got the problem that the HTMLWorker.ParseToList function will throw an exception ( 404 - not found ) when a tag like: <img alt="none" src="/image.jpg" /> has a deadlink in the src... i'd like it to just not load the image and go on... Does anyone now a way to configure this or has similar solution in mind?

    Read the article

  • iTextSharp - Bug in the table functions?

    - by Matthias
    Hello all together, I try to make a table like this: PdfPTable Table = new PdfPTable(6); PdfPCell Cell = new PdfPCell(new Phrase("a", Font1)); Cell.Rowspan = 2; Cell.Colspan = 2; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("b", Font1)); Cell.Rowspan = 2; Cell.Colspan = 2; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("c", Font1)); Cell.Colspan = 2; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("d", Font1)); Cell.Colspan = 2; Table.AddCell(Cell); That works fine. But changing the number of columns will destory the table. Is it a bug or do I make something wrong? This code destroys the table: PdfPTable Table = new PdfPTable(17); PdfPCell Cell = new PdfPCell(new Phrase("a", Font1)); Cell.Rowspan = 2; Cell.Colspan = 2; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("b", Font1)); Cell.Rowspan = 2; Cell.Colspan = 10; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("c", Font1)); Cell.Colspan = 5; Table.AddCell(Cell); Cell = new PdfPCell(new Phrase("d", Font1)); Cell.Colspan = 5; Table.AddCell(Cell); Edit: The table should have this layout: |-------------------------------------------------------| | Cell "a" with | Cell "b" with | Cell "c", colspan = 5 | | colspan = 2 | colspan = 10 |-----------------------| | rowspan = 2 | rowspan = 2 | Cell "d", colspan = 5 | |-------------------------------------------------------| Best regards, Matthias

    Read the article

  • iTextSharp Set content of ListBox?

    - by Petoj
    Well im trying to set the content of a ListBox but even if it returns true nothing happens.. PdfStamper stamper = new PdfStamper(reader, context.Response.OutputStream); AcroFields fields = stamper.AcroFields; bool result = fields.SetListOption("listbox", data.ToArray(), data.ToArray()); So what am i doing wrong the data never gets to the pdf?

    Read the article

  • Populating PDF fields in .NET without a API, such as iTextSharp

    - by Kristjan Oddsson
    class mineTest { string pdfTemplate = @"c:\us.pdf"; public mineTest(Customer c, string output) { StreamReader sr = new StreamReader(pdfTemplate); StreamWriter sw = new StreamWriter(output); string content = sr.ReadToEnd(); content.Replace("(Customer name)/DA(/Verdana 10 Tf 0 g)/FT/Tx/Type/Annot/MK<<>>/V()/AP<</N 13 0 R>>>>", "(Customer name)/DA(/Verdana 10 Tf 0 g)/FT/Tx/Type/Annot/MK<<>>/V(John Johnson)/AP<</N 13 0 R>>>>"); sw.Write(content); sw.Close(); sr.Close(); } } Why does the above code fail at producing a valid PDF?

    Read the article

  • Simple Merging Of PDF Documents with iTextSharp 5.4.5.0

    - by Mladen Prajdic
    As we were working on our first SQL Saturday in Slovenia, we came to a point when we had to print out the so-called SpeedPASS's for attendees. This SpeedPASS file is a PDF and contains thier raffle, lunch and admission tickets. The problem is we have to download one PDF per attendee and print that out. And printing more than 10 docs at once is a pain. So I decided to make a little console app that would merge multiple PDF files into a single file that would be much easier to print. I used an open source PDF manipulation library called iTextSharp version 5.4.5.0 This is a console program I used. It’s brilliantly named MergeSpeedPASS. It only has two methods and is really short. Don't let the name fool you It can be used to merge any PDF files. The first parameter is the name of the target PDF file that will be created. The second parameter is the directory containing PDF files to be merged into a single file. using iTextSharp.text; using iTextSharp.text.pdf; using System; using System.IO; namespace MergeSpeedPASS { class Program { static void Main(string[] args) { if (args.Length == 0 || args[0] == "-h" || args[0] == "/h") { Console.WriteLine("Welcome to MergeSpeedPASS. Created by Mladen Prajdic. Uses iTextSharp 5.4.5.0."); Console.WriteLine("Tool to create a single SpeedPASS PDF from all downloaded generated PDFs."); Console.WriteLine(""); Console.WriteLine("Example: MergeSpeedPASS.exe targetFileName sourceDir"); Console.WriteLine(" targetFileName = name of the new merged PDF file. Must include .pdf extension."); Console.WriteLine(" sourceDir = path to the dir containing downloaded attendee SpeedPASS PDFs"); Console.WriteLine(""); Console.WriteLine(@"Example: MergeSpeedPASS.exe MergedSpeedPASS.pdf d:\Downloads\SQLSaturdaySpeedPASSFiles"); } else if (args.Length == 2) CreateMergedPDF(args[0], args[1]); Console.WriteLine(""); Console.WriteLine("Press any key to exit..."); Console.Read(); } static void CreateMergedPDF(string targetPDF, string sourceDir) { using (FileStream stream = new FileStream(targetPDF, FileMode.Create)) { Document pdfDoc = new Document(PageSize.A4); PdfCopy pdf = new PdfCopy(pdfDoc, stream); pdfDoc.Open(); var files = Directory.GetFiles(sourceDir); Console.WriteLine("Merging files count: " + files.Length); int i = 1; foreach (string file in files) { Console.WriteLine(i + ". Adding: " + file); pdf.AddDocument(new PdfReader(file)); i++; } if (pdfDoc != null) pdfDoc.Close(); Console.WriteLine("SpeedPASS PDF merge complete."); } } } } Hope it helps you and have fun.

    Read the article

  • Filling in PDF Forms with ASP.NET and iTextSharp

    The Portable Document Format (PDF) is a popular file format for documents. PDF files are a popular document format for two primary reasons: first, because the PDF standard is an open standard, there are many vendors that provide PDF readers across virtually all operating systems, and many proprietary programs, such as Microsoft Word, include a "Save as PDF" option. Consequently, PDFs server as a sort of common currency of exchange. A person writing a document using Microsoft Word for Windows can save the document as a PDF, which can then be read by others whether or not they are using Windows and whether or not they have Microsoft Word installed. Second, PDF files are self-contained. Each PDF file includes its complete text, fonts, images, input fields, and other content. This means that even complicated documents with many images, an intricate layout, and with user interface elements like textboxes and checkboxes can be encapsulated in a single PDF file. Due to their ubiquity and layout capabilities, it's not uncommon for a websites to use PDF technology. For example, when purchasing goods at an online store you may be offered the ability to download an invoice as a PDF file. PDFs also support form fields, which are user interface elements like textboxes, checkboxes, comboboxes, and the like. These form fields can be entered by a user viewing the PDF or, with a bit of code, they can be entered programmatically. This article is the first in a multi-part series that examines how to programmatically work with PDF files from an ASP.NET application using iTextSharp, a .NET open source library for PDF generation. This installment shows how to use iTextSharp to open an existing PDF document with form fields, fill those form fields with user-supplied values, and then save the combined output to a new PDF file. Read on to learn more! Read More >

    Read the article

  • Can I flip the coordinate system without flipping text in iTextSharp?

    - by I. J. Kennedy
    I have some chart-creating code written for a coordinate system in which a y-coordinate of 0 is the top of the page. We are now converting to iTextSharp, which uses the conventional system from mathematics where a y-coordinate of 0 is the bottom of the page. There are many calculations involved in producing the chart and I'd like to not mess with those calculations. I can partially "fix" the problem by transforming iTextSharp's coordinate system like this: pdfContentByte.ConcatCTM(1f, 0f, 0f, -1f, 0f, pdfDoc.PageSize.Height); This works great for lines, rectangles, and circles, but the text is now upside down! Is there a way to remedy this, using SetTextMatrix or otherwise?

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >