ABCpdf - nice component but not free

June 23rd, 2008 by ganton | Print

Last time I wrote that I need a pdf component but it will be nice if I can get it for free. ABCpdf component has an offer for receiving it free but when I read websupergoo’s free license guidlinesI understand that it is not for me because I cannot fulfil their requirements for receiving free license. But I reviewed its option for programatically filling fields of an existing reports (it is what I need) and drawing a string in target rectangle. They have nice support for these options, a intuitive object model and good documentation. I found many examples and explanations in their docs as well they have examples coming with installation package. It is really easy to work with their object model at least what I’ve seen. To change a field we need to know its name or index (see below)

   1: // Initialization of document

   2: using (Doc doc = new Doc())    

   3: {     

   4:     // Reading the document     

   5:     doc.Read(@"c:\_anton\test.pdf");     

   6:     // set value by index or by name     

   7:     doc.Form.Fields[0].Value = "some value";     

   8:     doc.Form.Fields["nameTextField"].Value = "some value";     

   9:     // set value of all fields which name ends with "TextField"     

  10:     foreach (Field field in doc.Form.Fields)     

  11:     {      

  12:         if (field.Name.EndsWith("TextField"))      

  13:         {       

  14:             field.Value = "some value";       

  15:         }

  16:     }     

  17:     doc.Save(@"c:\_anton\output_test.pdf");    

  18: }

Another option is to just draw text in some rectangle where a new text is needed.

   1: // Initialization of document    

   2: using (Doc doc = new Doc())    

   3: {     

   4:     // Reading the document     

   5:     doc.Read(@"c:\_anton\test.pdf");     

   6:     // Draws a grid into document and we can see where our element is in pixels     

   7:     // Each square is 10×10 pixels The grid has normal coordinate system.     

   8:     // Its (0,0) is placed at bottom left corner of the document     

   9:     doc.AddGrid();     

  10:     // snippet 1     

  11:     // set parameters for writing     

  12:     doc.FontSize = 12;     

  13:     doc.Color.Color = Color.Aqua;     

  14:     // using SetRect for setting coordinates we will have (x,y) placed according to the grid     

  15:     doc.Rect.SetRect(10, 10, 50, 20);     

  16:     doc.FillRect();     

  17:     // we should reset the color because there is no separate color for Text and Background     

  18:     doc.Color.Color = Color.Black;     

  19:     doc.AddText("some text");          

  20:     // snippet 2     

  21:     doc.Color.Color = Color.Aqua;     

  22:     // using direct set of the rectangle our (x, y) will be estimated from top left corner of the document     

  23:     doc.Rect.Rectangle = new Rectangle(10, 10, 50, 20);         

  24:     doc.FillRect();     

  25:     doc.Color.Color = Color.Black;     

  26:     doc.AddText("some text");     

  27:     doc.Color.Color = Color.Aqua;     

  28:     doc.Save(@"c:\_anton\output_test.pdf");    

  29: }

The result of snippet 1 is on the left side picture and snippet 2 is on the right side of the picture.

3 Responses to “ABCpdf - nice component but not free”

  1. Ranga Says:

    Hello,

    You can also use the DynamicPDF for .NET product from ceTe Software Pvt Ltd. Our products will allow you to create PDF documents programmatically from scratch, merge existing PDF documents, add contents to existing PDF files, stamping PDFs, appending existing PDF documents, form filling, rotating and scaling PDFs, etc.

    You can merge the existing PDF documents and read or fill the form fields without any problem. You can add any page elements to an existing PDF document.

    Following is some sample code for filling the form fields of an existing PDF document.

    //Merge the existing PDF document
    MergeDocument document = new MergeDocument(@”C:\Temp\DocumentA.pdf”);

    //loop through the fields to fill
    foreach (FormField field in document.Form.Fields)
    {
    //Fill the field using the field name.
    document.Form.Fields[field.FullName].Value = “ceTe Software”;
    }

    //open the PDF on the browser
    document.DrawToWeb();

    You can fill the fields using the index or the name of the form field.

    You can add any page element ( labels, textareas, tables, formattedtext etc ) to a newly creating PDF or to an existing PDF without any problem.

    //Create a new PDF document object
    Document document = new Document();

    //Create a new Page object
    Page page = new Page();

    //Create a rectangle element
    Rectangle rectangle = new Rectangle(10, 10, 100, 100);
    rectangle.FillColor = RgbColor.Gray;

    //Create a label element
    Label label = new Label(”ceTe Software”, 10, 10, 100, 100);

    //Add rectangle and label to the page
    page.Elements.Add(rectangle);
    page.Elements.Add(label);

    //Add page to the document
    document.Pages.Add(page);

    //Save the PDF to disk
    document.Draw(@”C:\Temp\Doc.pdf”);

    You can save the PDF to disk or open in the web browser, you can also output it to a byte array or a stream.

    You can refer to our website at http://www.cete.com.

    Thanks,

    Ranga.
    ceTe Software Support Team.

  2. ganton Says:

    Hi Ranga,

    Thanks for the information!

    I’ve also reviewed DynamicPDF for .Net component but
    I needed a pdf component for a very small project and that is why I’ve looked for a free one (the customer will not pay for it) or with option to get it for free. Unfortunately, I’ve not found any information how to get a free license for DynamicPDF for .Net component.

    Regards,
    ganton

  3. PdfSharp - a free component for editing pdf in .Net : Anton Gochev’s Weblog Says:

    [...] i wrote in my previous post ABCpdf is a nice component but I need something for free. I searched for some  free component and [...]

Leave a Reply