We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting attachments from XAF form Using Aspose Pdf

We have some pdf form defined using adobe lifecycle designer. So, they are XAF forms

First I am not able to get the field values, I tried using GetFieldNames method and then got all the fieldnames and trying looking at XFA name based index, then also I could not. What I could only do is get the fieldnames or export the whole file as xml.

Second I tried following the following link, to get the attachments and no result as well.

Please let us know how can we do this.

Regards

Mohit Thakral

Hi Mohit,


Thanks for using our products.

Can you please share the sample PDF file so that we can test the scenario at our end. We are sorry for this inconvenience.

Please find attached the PDF you had requested, it has multiple attachments uploaded within it.

Hi Mohit,


Thanks for sharing the resource file.

I have tested the scenario with Aspose.Pdf for .NET 7.7.0 while using following code snippet and I am unable to notice any problems. All the attachments are being extracted from XFA form.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/Application_Fillable_PDF.pdf");

//get embedded files collection

EmbeddedFileCollection embeddedFiles = pdfDocument.EmbeddedFiles;

//get count of the embedded files

Console.WriteLine("Total files : {0}", embeddedFiles.Count);

//loop through the collection to get all the attachments

foreach (FileSpecification fileSpecification in embeddedFiles)

{

Console.WriteLine("Name: {0}", fileSpecification.Name);

Console.WriteLine("Description: {0}",fileSpecification.Description);

Console.WriteLine("Mime Type: {0}", fileSpecification.MIMEType);

//check if parameter object contains the parameters

if (fileSpecification.Params != null)

{

Console.WriteLine("CheckSum: {0}",fileSpecification.Params.CheckSum);

Console.WriteLine("Creation Date: {0}",fileSpecification.Params.CreationDate);

Console.WriteLine("Modification Date: {0}",fileSpecification.Params.ModDate);

Console.WriteLine("Size: {0}", fileSpecification.Params.Size);

}

//get the attachment and write to file or stream

byte[] fileContent = new byte[fileSpecification.Contents.Length];

fileSpecification.Contents.Read(fileContent, 0,fileContent.Length);

FileStream fileStream = new FileStream("c:/pdftest/Attachment_"+fileSpecification.Name,FileMode.Create);

fileStream.Write(fileContent, 0, fileContent.Length);

fileStream.Close();

}

I was trying with version 7.3.0, it seems to be working with version 7.7.0.


Thanks a ton

Hi,


Seems like it is only getting back few attachments Things to Do to begin testing.txt ,CongressionalDistricts.xls, 3000 chars.txt and image.jpeg.

I am not able to get the other attachments. Can you please guide, along with that what about getting all the fieldnames and there values, as of now we are exporting xml as it is.

Regards
Mohit Thakral

Hi Mohit,


Can you please confirm that you are using Aspose.Pdf for .NET in licensed mode ? Please note that when using the component in trial mode, only 4 annotations / attachments can be extracted from PDF file.

Hi,

Our company has the license for Aspose, but we were testing the attachments extraction in trial mode. Will try with licensed version to confirm that all attachments can be extracted.

The file that we sent has multiple PDF forms that can be filled out by users. Can you provide us the sample code to extract each of the 9 fillable forms as separate PDF documents?

Thanks


Hi Mohit,


When extracting the attachments, the extracted files are saved with the extension and format in which they were added to PDF document. Please try using the product in licensed mode and in case you encounter any issue while using the extracted PDF forms, please feel free to contact.
Thanks a ton, Shahbaz. I tried in lic mode for 7.3.0 but that didn't work. I have following 2 question now.

First question is this pdf consists of lot of child forms. Is there any way we can split or get the child forms separately.

second is we have license for 7.3.0 but not for 7.7.0. Do you know why it is not working in case of 7.3.0

Regards
Mohit Thakral

aspose_007:
First question is this pdf consists of lot of child forms. Is there any way we can split or get the child forms separately.
Hi Mohit,

I have tried extracting the attachments using code snippet which I have shared earlier with Aspose.Pdf for .NET 7…80 and as per my observations, when I have used a licensed version, all the attachments are being extracted. For your reference, I have also attached the files/documents extracted over my end.

aspose_007:
we have license for 7.3.0 but not for 7.7.0. Do you know why it is not working in case of 7.3.0
In my earlier attempt, I have tested the scenario with v7.8.0 and all attachments are being extracted. I am not sure if v7.3.0 will work or not but we always recommend our customers to try using the latest release versions as they include the fixes for issues reported in earlier versions.

Hi Shahbaz,


Thanks a ton for getting all the attachments and this is good.
I tried and I also got the attachment part, and yes it seems to be working with 7.7.0.

But now my question is different, this particular pdf has child form sort of things, can we extract/split individual forms not attachments to the forms but forms itself

Regards
Mohit Thakral


Hi Mohit,


Thanks for your query. You can easily extract/split Pdf document using Aspose.Pdf. Please check following documentation details/code snippet. Hopefully it will serve the purpose.


Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal,


Thanks for the reply. Have a look at the attached pdf, it is not exactly just spiting or extracting the pdf. There are nested forms, which are shown only one user click on some buttons. Not only that we dont know how long those forms might be or how many pages those forms might have. Can you please guide us ?

Thanks a Lot

Regards
Mohit Thakral

Hi Mohit,

Sorry for the delayed response. I'm afraid currently Aspose.Pdf supports extraction of attachments and splitting the pages according to given page no. parameters.

As per my understanding, your attachment has different merged sub forms and user can navigate to a desired sub form either by selecting form from list and clicking button or scrolling down manually. The button refers to some specific pages upon related selection. So IMO you can extract specific pages of forms.

However, I have logged an investigation ticket as PDFNEWNET-35148 in our issue tracking system for further investigation. We will update you about the issue progress via this forum thread.

Best Regards,