We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Fill PDF and Flatten option

Thread ID:

Created:

Updated:

Platform:

Replies:

130671 May 24,2017 04:08 PM UTC May 29,2017 01:10 PM UTC Xamarin.Forms 5
loading
Tags: PDF
Benjamin
Asked On May 24, 2017 04:08 PM UTC


Hello,

We're working with a PDF file : We need to fill and print it.

it's a official document (from French gvt) and we need to fill it.

We succeed to fill it but not to "Flatten" it (if flattened, all fields are blank in the result document).
We're using a workaround : Set the final document as Readonly but we have then another problem to print it : All fields are blank on the printed document.

==> My question is : How can i completely "Flatten" this PDF document to be able to correctly print it.

I joined a test project :
It's a console program which will be start (with parameters) by another application.
You will find 2 commands : FILL and PRINT
- FILL which will fill the empty document and save it to the result document
- PRINT will print any of the 2 documents to a printer

In the Main() function your will find 2 block of code to test the FILL command and the PRINT command.

Please let the project in debug mode to test it.

Thanks in advance for your help,

Best regards,

Benjamin

Attachment: PDFUtils_78f8705a.zip

Surya Kumar [Syncfusion]
Replied On May 25, 2017 02:29 PM UTC

Hi Benjamin, 
 
Thank you for using Syncfusion products. 
 
We have analyzed the document which you have given, it is found that the document was XFA document which contains XFA form fields, since we do not have support to flatten the XFA form fields, we have created a work around to flatten the fields. 
 
The XFA forms can be flattened when, the XFA document is imported and saved as normal document then the saved document can be used to filling forms and flattening it directly, please find the code snippet for the same below: 
  
            //Load the XFA document 
            PdfLoadedDocument lDoc = new PdfLoadedDocument(source); 
 
            //Create new document to save the imported document 
            PdfDocument document = new PdfDocument(); 
            //Imports the pages from the lDoc 
 
            document.ImportPageRange(lDoc, 0, lDoc.Pages.Count - 1); 
 
            //Saves the document 
 
            document.Save("sample.pdf"); 
 
We have altered the sample which you have posted in last update with the workaround mentioned above, please find the sample from the below link: 
 
Please let us know if you need any further information. 
 
Regards, 
Surya Kumar 


Benjamin
Replied On May 26, 2017 03:50 PM UTC

Hello, With your workaround, we can fill the PDF document and display it.But we still have the print problem : When we try to silently print the filled document, all fields are empty (but inserted images are present).Edit : Another question, how can i know that a PDF document is a XFA document ?I joined a PDF exemple to this message.Thanks in advance for your help, Best regards, Benjamin Attachment: cerfa2_1e165816.zip

Benjamin
Replied On May 26, 2017 03:51 PM UTC

Hello, With your workaround, we can fill the PDF document and display it.But we still have the print problem : When we try to silently print the filled document, all fields are empty (but inserted images are present).Edit : Another question, how can i know that a PDF document is a XFA document ?I joined a PDF exemple to this message.Thanks in advance for your help, Best regards, Benjamin Attachment: cerfa2_1e165816.zip

The "Edit" function massacred my message.

I join here the PDF document.

Attachment: cerfa2_9894b506.zip

Surya Kumar [Syncfusion]
Replied On May 29, 2017 12:59 PM UTC

Hi Benjamin, 
 
We can use the below code snippet to find whether the loaded document is normal or XFA document. 
 
private bool IsXFADocument (string filePath) 
{ 
            bool isXfa = false; 
 
        PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(filePath); 
            //Get the loaded XFA form. 
 
            PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; 
 
            int count = loadedForm.Fields.Count; 
        //If the loaded field count is greater than zero then its a XFA document. 
            if (count > 0) 
                isXfa = true; 
            return isXfa; 
        loadedDocument.Close(); 
 
} 
 
We have created the support incident for the issue with “The flatten form fields value become empty when Silent printed the particular PDF document” it can be tracked through below link: 
  
  
Let us know if you need any further information in this. 
Regards, 
Surya Kumar. 


Surya Kumar [Syncfusion]
Replied On May 29, 2017 01:10 PM UTC

Hi Benjamin, 
 
We can use the below code snippet to find whether the loaded document is normal or XFA document. 
 
private bool IsXFADocument (string filePath) 
{ 
            bool isXfa = false; 
 
           PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(filePath); 
         //Get the loaded XFA form. 
 
            PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; 
 
            loadedDocument.Close(); 
 
            int count = loadedForm.Fields.Count; 
        //If the loaded field count is greater than zero then its a XFA document. 
            if (count > 0) 
                isXfa = true; 
            return isXfa; 
 
} 
 
 
We have created the support incident for the issue with “The flatten form fields value become empty when Silent printed the particular PDF document” it can be tracked through below link: 
 
Let us know if you need any further information in this. 
 
Regards, 
Surya Kumar. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;