Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jun 06, 2014 7:46 am

Hey everyone,

I just wrote a short (two lines, which I'll post below) app to test the free, NuGet-available Spire.PDF to try and read a PDF and get its form fields. I've tried it with two files (It says I can't post URLs, but I think they're probably important so I've added spaces and replaced periods with commas. My apologies for the trouble. www , ppt , gc , ca / form / pdfs / pptc153 , pdf and www , uspto , gov / forms / aia0014 , pdf) and neither seem to be working. My two lines are as follows:
Code: Select all
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile("{downloaded file path}");

After executing them, I've been looking through the doc variable with a Watch window and I've found that doc.Form.Fields is an empty collection.
Curiously, it seems that the USPTO form isn't getting loaded at all. doc.Pages only has one item and when I save it to an image, that image is blank. This is not the case for the PPT one, but it still doesn't show as having any form fields.
Am I missing a step? Or is there something (security-wise, maybe? or the wrong format?) that could be doing this by design?

Thanks,
Matthew

MHaugen
 
Posts: 2
Joined: Fri Jun 06, 2014 7:07 am

Fri Jun 06, 2014 11:26 am

Hi,
Thanks for your inquiry.
We did some test with your pdf files with the latest release Spire.PDF v3.0.43 (sorry, Spire.PDF Free Edition has no that version), we could get fields from pptc153.pdf and failed in getting field from aia0014.pdf. Using the code below
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"aia0014.pdf");
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
    PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
    Console.WriteLine(field.Name);
}

we found pptc153.pdf has 183 fields.
And via the code
Code: Select all
FileInfo file = new FileInfo(@"pptc153.pdf");
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(file.FullName);

//save to images
for (int i = 0; i < doc.Pages.Count; i++)
{
   String fileName = String.Format("{0}-img-{1}.png", file.Name, i);
   using (Image image = doc.SaveAsImage(i))
   {
      image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
   }
}

we could convert it to images. And we could not yet convert the pdf file aia0014.pdf to images. It looks like there is some issue during parsing this pdf file. We have post your file to our dev team. We will try to fix it and then, we will inform you.

Thanks.
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Sat Jun 07, 2014 7:58 pm

Thank you for your reply.

Do you think the issue for pptc153.pdf is my version of Spire.PDF? And if so, I'd rather not have to get the paid version since the free one does everything I want so do you have any idea when the free one might be updated to the newer version? Is that in the works now?
Also, unfortunately, aia0014.pdf is the actual pdf I need to work, I only tried the other one as a test when it didn't work. So I guess we'll see what your dev team has to say and hopefully it won't be too big a deal.

Thanks again and sorry, I know issues that get passed along to devs are always frustrating,
Matthew

MHaugen
 
Posts: 2
Joined: Fri Jun 06, 2014 7:07 am

Mon Jun 09, 2014 7:47 am

Dear Matthew,

Thanks for your response.
We will provide you a newer Free version when the issues are resolved.
We will do our best to resolve it soon. Once it is resolved, we will inform you.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Mar 23, 2022 8:20 am

Dear Matthew,

Sorry for the long silence.
I'm glad to tell you that our Spire.Office supports parsing the xfa form fields of aia0014.pdf. Now commercial Spire.Office has been released. Welcome to download and test Spire.Office Platinum(Hotfix) Version:7.3.2.
Website link: https://www.e-iceblue.com/Download/download-office-for-net-now.html
Nuget links:
https://www.nuget.org/packages/Spire.Office/7.3.2
https://www.nuget.org/packages/Spire.Officefor.NETStandard/7.3.2
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("aia0014.pdf");
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
List<XfaField> xfafields = formWidget.XFAForm.XfaFields;
StringBuilder stringBuilder = new StringBuilder();
foreach (XfaField xfaField in xfafields)
{
  stringBuilder.AppendLine(xfaField.FieldType + "----" + xfaField.Name + "---" + xfaField.ToString());
 }


I will inform you when new free Spire.Office is released.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF