ABCpdf - nice component but not free



By ganton ~ June 23rd, 2008. Filed under: .Net tools.

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)

   // Initialization of document
using (Doc doc = new Doc())    
{     
    // Reading the document     
    doc.Read(@"c:\_anton\test.pdf");     
    // set value by index or by name     
    doc.Form.Fields[0].Value = "some value";     
    doc.Form.Fields["nameTextField"].Value = "some value";     
   // set value of all fields which name ends with "TextField"     
   foreach (Field field in doc.Form.Fields)     
   {      
       if (field.Name.EndsWith("TextField"))      
       {       
           field.Value = "some value";       
       }          
   }     
   doc.Save(@"c:\_anton\output_test.pdf");    
}

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

 

      // Initialization of document    
using (Doc doc = new Doc())    
{     
   // Reading the document     
   doc.Read(@"c:\_anton\test.pdf");     
   // Draws a grid into document and we can see where our element is in pixels     
   // Each square is 10x10 pixels The grid has normal coordinate system.     
   // Its (0,0) is placed at bottom left corner of the document     
   doc.AddGrid();     
   // snippet 1     
   // set parameters for writing     
   doc.FontSize = 12;     
   doc.Color.Color = Color.Aqua;     
   // using SetRect for setting coordinates we will have (x,y) placed according to the grid     
   doc.Rect.SetRect(10, 10, 50, 20);     
   doc.FillRect();     
   // we should reset the color because there is no separate color for Text and Background     
   doc.Color.Color = Color.Black;     
   doc.AddText("some text");          
   // snippet 2     
   doc.Color.Color = Color.Aqua;     
   // using direct set of the rectangle our (x, y) will be estimated from top left corner of the document     
   doc.Rect.Rectangle = new Rectangle(10, 10, 50, 20);         
   doc.FillRect();     
   doc.Color.Color = Color.Black;     
   doc.AddText("some text");     
   doc.Color.Color = Color.Aqua;     
   doc.Save(@"c:\_anton\output_test.pdf");    
}

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

    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

    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

    [...] 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