Tech Off Thread

80 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Conversation Locked

This conversation has been locked by the site admins. No new comments can be made.

ASP.NET and iTextSharp (free PDF Generator for .NET)

Back to Forum: Tech Off
  • User profile image
    elrocael

    ManniAT said:
    Hi Guys,

    I'm new to iTextSharp (and general PDF devel).
    Can anyboy give me some "startup" how to digital sign a PDF document?
    As far as I know signed PDFs there are two kinds of.
    One is simply signed - and the other one is a "Certified Document".

    In Acrobat I get asked (when I am the first signer) if I want to certify the document.

    And furtheron  - there tow kinds of signing - one is with a visible signature - and one is without it.

    My primary goal is to
    a.) open an existing PDF
    b.) select a certificate from the users CertStore (CryptoAPI)
    c.) create a "Certified document" with the selected key
    d.) place a visula representation of it on the last page of the document.

    Regards

    Manfred

     

    Spanish

    Muchas gracias amigo, el codigo me sirvió de mucho, lo imprementé de la siguiente manera...

     

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

     

    Public

     

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim m As MemoryStream = New MemoryStream()' which document to open

    Dim file As String = ("c:\prueba.pdf")

    Dim reader As PdfReader = New PdfReader(file)'

     

     

     

    TextBox1.Text = TextBox1.Text & name1

     

    End

     

     

    Dim outStamper As PdfStamper = New PdfStamper(reader, m)Dim name1 As String = outStamper.AcroFields.GetField("Texto2") 'este es le nombre del campo de texto pdf End Sub Class

     

     

     

    System System.IO iTextSharp.text iTextSharp.text.pdf System.Data System.Text System.Drawing System.ComponentModel System.Collections Class Form1

  • User profile image
    LesFerg

    Just a quick note regarding the subject "free PDF generator"; in December 2009 the license for iTextSharp became "Affero GNU Public License", so when used with a commercial application, e.g. non-open-source, this library requires commercial licensing.

  • User profile image
    pei

    hi, im new here. im involved in a project where i need to fill a form that has multi-line blanks. The thing is that some of these empty spaces that need to be filled are multi-line and the first line does not start where the rest does. So as to explain myself, i mean something like this:

     

    XXXXXXXXXXXXX

    XXXX____________

    __________________

    XXXXXXXXXXXXX

     

    I inserted an acro field with margins but and if i write manually it works like a charm. I managed to recover the data from the DB and put it in the empty spaces but the thing is that when i open the pdf i see the acro fields that are single line do not have problems but those that are multi-line do not fit into the created margin. The inserted text starts where the line starts, without consideration of the margin. Now, if i click into the acro field then the text fits into the space perfectly. Once i click on another place of the document, the text goes back to the beggining of the line.

     

    How can i solve this?

    Thx even for reading this, im sorry for reopening the thread and for my bad english. Smiley

  • User profile image
    fchivu

    Use a HTML to PDF converter for .NET . Is the easiest way to produce rich PDF documents on the fly.

  • User profile image
    pei

    fchivu said:

    Use a HTML to PDF converter for .NET . Is the easiest way to produce rich PDF documents on the fly.

    i dont want any more products, i just want to know how can i make the text i add fit in the blanks like its supossed to.

     

    ANY IDEAS?

     

    thanks in advance

  • User profile image
    Nobels

    pei said:
    fchivu said:
    *snip*

    i dont want any more products, i just want to know how can i make the text i add fit in the blanks like its supossed to.

     

    ANY IDEAS?

     

    thanks in advance

    check this: http://itextsharp.sourceforge.net/tutorial/

     

    please create small example and post it or contact me.

     

     

     

     

  • User profile image
    fchivu

    You can check the HTML to PDF library for .NET or the HTML to PDF online for free 

  • User profile image
    polarwarp

    Ok I've gotten my pdfstamping working with iTextsharp but I can't figure out how to control the font size of the fillable text fields.  Is this something that needs to be done at the template level (I don't have Adobe Professional - I'm relying on someone else doing the pdf)? Or can I control it via code??

     

    I have tried:

     

                BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
                PdfContentByte content = pdfStamper.GetOverContent(1);
                content.BeginText();
                content.SetFontAndSize(baseFont, 10);

                //Populate the PDF form with the FDF key/value pairs
                AcroFields pdfForm = pdfStamper.AcroFields;
                pdfForm.SetFields(fdfReader);
                content.EndText();
                content.Stroke();

                //todo stopped jere
                pdfForm.SetFieldProperty("MemberEmail", "textfont", baseFont, null);


                //’Flatten’ (make the text go directly onto the pdf) and close the form
                pdfStamper.FormFlattening = true;
                pdfStamper.Writer.CloseStream = true;
                pdfStamper.Close();

     

    But there is no change at all to the font.

     

    I'm struggling to find anyone who combines filling a pdf template with data with the ability to control font?!!

     

    Thanks Smiley

  • User profile image
    fchivu

    You can use this HTML to PDF  library or a HTML to PDF online service.

  • User profile image
    fchivu

    Filth said:

    Hi,

    I've just starting using iTextSharp in a code behind page, but when I run it, it just shows a empty pdf.

    I was wondering if anyone could see anything crazy that I have or haven't done?

    The code in my page_load event is:

    MemoryStream m = new MemoryStream();

    Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);

    try

    {

    Response.ContentType = "application/pdf";

    PdfWriter.GetInstance(document, m);

    document.Open();

    document.Add(new Paragraph(DateTime.Now.ToString()));

    document.Add(new Paragraph("This is another test"));

    document.Add(new Paragraph("Yet another test"));

    }

    catch (DocumentException ex)

    {

    Console.Error.WriteLine(ex.StackTrace);

    Console.Error.WriteLine(ex.Message);

    }

    // step 5: Close document

    document.Close();

    // step 6: Write pdf bytes to outputstream

    Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);

    Response.OutputStream.Flush();

    Response.OutputStream.Close();

    You can use this HTML to PDF  library or a HTML to PDF online service.

  • User profile image
    chidnyc

    fchivu said:
    Filth said:
    *snip*

    You can use this HTML to PDF  library or a HTML to PDF online service.

    Hello,

     

    I have a doubt. I want to merge few pdf's into one. I am able to do it using iTextSharp. However, i notice that the page numbers do not change. If i merge two pdf with 4 pages each, i would want the final merged pdf to have a page numbering from 1 - 8;  whats happening now is that i have the merged pdf with the page numbering 1-4 and again 1-4.

    How do i change the page numbers of the merged pdf's ?

     

    Thanks!

  • User profile image
    itsnotabug

    hello,

     

    in this thread i've read a lot of people are having problems dynamically creating form fields and controlling the text size/font with the pdfstamper. i too had problems because of the shared server situation and found the easiest solution was to instead use the watermark feature of iTextsharp.

     

    using a watermark you don't have to dynamically add any form fields... you just have to know the x and y coordinates of each field you want to "stamp". you can add as many watermarks as you want and they don't have to be opaque.... they can be any color, any size, any font installed on the server.

     

    pdf spec is device independent so the coordinates are exactly were you would place those form fields anyway. you may have to experiement with getting the coordinates right though and depending on your application this may be impractical.

     

    so set up your template and let it live on the server, then watermark the heck out of it Smiley

  • User profile image
    Rasool

    joachim said:
    I had similar problem. I just downloaded a trial of the latest version of the Adobe Acrobat, which has a cool form designer tool. I used that to create the template document for my program, including adding all the form fields.

    This works fine as long as you do not need to modify the template after it is created.

    My code then creates the PDF documents based on this template, by filling in values from database records, into form fields programmatically.

    Good luck...

    Hi every one

    I am using Itextsharp for converting the webpage gridview to the PDF

    every thing works fine but the only thing is I want to show the gridview in PDF with wrap in text in the columns as I have some long text

    in some columns.

    what would be the code.

     

    Any answers will be appreciated

     

  • User profile image
    fchiv

    Filth said:

    Hi,

    I've just starting using iTextSharp in a code behind page, but when I run it, it just shows a empty pdf.

    I was wondering if anyone could see anything crazy that I have or haven't done?

    The code in my page_load event is:

    MemoryStream m = new MemoryStream();

    Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);

    try

    {

    Response.ContentType = "application/pdf";

    PdfWriter.GetInstance(document, m);

    document.Open();

    document.Add(new Paragraph(DateTime.Now.ToString()));

    document.Add(new Paragraph("This is another test"));

    document.Add(new Paragraph("Yet another test"));

    }

    catch (DocumentException ex)

    {

    Console.Error.WriteLine(ex.StackTrace);

    Console.Error.WriteLine(ex.Message);

    }

    // step 5: Close document

    document.Close();

    // step 6: Write pdf bytes to outputstream

    Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);

    Response.OutputStream.Flush();

    Response.OutputStream.Close();

    you can try a html to pdf converter for library for .net or a free html to pdf online service

  • User profile image
    Oggelito

    I'm just jumping in here, haven't followe the entire thread. There's many PDF tools out there, for .NET and such, but it's a jungle. I want to promote PDFSharp (pdfsharp.net), It's an free .net library for PDF manipulation. There's vast documentation and a active forum where the author himself is active.

     

    I'm using this component in a current project where I create PDF's from scratch based on input from my database

     

  • User profile image
    Newvel

    fchivu said:

    You can use this HTML to PDF  library or a HTML to PDF online service.

    Hi Everybody,

    Can anyone solve my problem?

    I am having Two aspx page, Main.aspx and View.aspx. In main.aspx page i am having iframe in td. The src of iFrame is View.aspx.

       In the Pageload event of View.aspx page, i am loading the pdf as inline file.

     

    Now my user wants to edit the content of pdf(adding comments) using typewriter function.  So i want to save the pdf content as binary value in database.

     

    please see the following link:

    http://www.eggheadcafe.com/community/aspnet/17/10183194/getting-location-of-iframe-document-in-aspnet.aspx

     

    How to do this? Maill me if anyone know the solution.

    mailtosenthilvel@gmail.com

    Thanks in Advance.

     

     

    With Regards,

    Vel,

     

  • User profile image
    anjaneya

    joachim said:
    sbc wrote:
    Don't know why you have to go through all those stages just to modify a file


    You don't; like I said it's just a workaround. And yes, it's inefficient (especially if you're doing it on the server).

    But if it is just the Title you are worries about, then just set the title on the form template and when the new document is created with the stamper, the Title will still be there.

    hi

     

    i am new to  iTextSharp,any one please help me to convert .doc to pdf

  • User profile image
    Beetlejuice

    hi all,

    in several projects I used solution "wkhtmltopdf".
    First I tried iTextSharp, but it does not work well with converting html file to pdf file, and sometimes happened when displaying Cyrillic.

    "wkhtmltopdf" works fine, but it is an executable file

     

    Peace

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.