tags:

views:

70

answers:

2

I have some free C# code to parse PDF files, which I downloaded.

I have written code using these classes to extract information about the form fields, and generate a new PDF with the form fields populated.

Now I've discovered that it doesn't work with new PDF's, because new PDF's have streams where the old formats had plain text. I don't have the time to study the PDF format documentation and write my own PDF stream parser, so I'd like to know if anyone knows of a library or classes that I can use from C# / .Net.

Before you say "Use iTextSharp", the problem with iTextSharp is the license. I need code that can be used in commercial software. If you're unsure about the license, let me know anyway.

Thanks!

+1  A: 

Aspose's PDF kit seems to do the job. Hmmm... so I answer my own question... oh, well, if anyone knows any more, I'm still keen to hear about them.

Lost Hobbit
A: 

Hello!

You may try Docotic PDF Library. This library allows to fill in form fields with ease.

Here is a sample for your task:

using System.Collections.ObjectModel;

using BitMiracle.Docotic.Pdf;

namespace BitMiracle.Docotic.Samples
{
    public static class FillForm
    {
        public static void Main()
        {
            using (PdfDocument document = new PdfDocument("Some Document.pdf"))
            {
                ReadOnlyCollection<PdfWidget> widgets = document.Pages[0].Widgets;

                PdfTextBox textBox = (PdfTextBox)widgets[0];
                textBox.Text = "Some Name";

                PdfCheckBox checkBox = (PdfCheckBox)widgets[1];
                checkBox.Checked = true;

                PdfRadioButton firstRadioButton = (PdfRadioButton)widgets[2];
                firstRadioButton.Checked = false;

                PdfRadioButton secondRadioButton = (PdfRadioButton)widgets[3];
                secondRadioButton.Checked = true;

                document.Save("FillForm.pdf");
            }
        }
    }
}
Vitaliy Shibaev