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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PDFViewer Import JSON into Form

Thread ID:

Created:

Updated:

Platform:

Replies:

148113 Oct 6,2019 11:25 PM UTC Nov 1,2019 03:37 PM UTC Xamarin.Forms 3
loading
Tags: PdfViewer
MikeD
Asked On October 6, 2019 11:25 PM UTC

Hello,

   I'm trying to use a JSON string to pre-load some data into my fillable PDF document using the below code, however, the data doesn't load into the form and most of the time my app freezes up.  I am using all of the latest nuget packages as of the date of posting.  If you could please help me to understand how to use the ImportFormData function using JSON, preferably from a string (not a file), that would be amazing.  Thank you!

        public PDFFormFillerPage()
        {
            Title = "PDF";
            SfPdfViewer pdfViewer;
            pdfViewer = new SfPdfViewer();
            pdfViewer.Toolbar.Enabled = false;            
            Grid grid = new Grid();
            grid.Children.Add(pdfViewer);
            Content = grid;
            

            Stream fileStream;
            PdfDocument document;
            PdfTextBoxField textBoxField;

            // Create a new PDF document
            document = new PdfDocument();
            document.PageSettings.Margins.All = 0;

            //Add a page to the document
            PdfPage page = document.Pages.Add();

            //Create a textbox field and add the properties.
            textBoxField = new PdfTextBoxField(page, "FirstName");
            textBoxField.Bounds = new Syncfusion.Drawing.RectangleF(0, 0, 500, 100);
            //Add the form field to the document.
            document.Form.Fields.Add(textBoxField);

            textBoxField.Text = "Test";

            //Save the document to the stream
            fileStream = new MemoryStream();
            document.Save(fileStream);

            //Close the document
            document.Close(true);

            //Load the PDF
            pdfViewer.LoadDocument(fileStream);
            fileStream.Close();

            string jsonData = @"{'FirstName':'Mike'}";
            byte[] byteArray = Encoding.Unicode.GetBytes(jsonData);


            using (MemoryStream stream = new MemoryStream(byteArray))
            {
                pdfViewer.ImportFormData(stream, DataFormat.Json);
            }
        }

Jhansi Priya Ramesh [Syncfusion]
Replied On October 7, 2019 12:55 PM UTC

Hi Micheal, 
 
We could able to reproduce the issue of “Form Field data not imported using ‘ImportFromData’ API. We have forwarded this issue to our development team. We will update further details on 9th October 2019. 
 
Regards, 
Jhansi Priya Ramesh 


Jhansi Priya Ramesh [Syncfusion]
Replied On October 9, 2019 03:30 PM UTC

Hi Micheal, 

Sorry for the inconvenience caused. 

We are still validating the issue of “Form Field data not imported using ‘ImportFromData’ API” .We will validate further details on 11th October 2019. 

Regards, 
Jhansi Priya Ramesh 


Jhansi Priya Ramesh [Syncfusion]
Replied On November 1, 2019 03:37 PM UTC

Hi  Micheal, 
 
The issue with “
Form Field data not imported using ‘ImportFromData’ API has been fixed and the patch for this fix can be downloaded from the following location.  
 
Recommended approach - exe will perform automatic configuration 
Please find the patch setup from below location: 
 

 Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment 
Please find the patch assemblies alone from below location: 
 
   
NuGet:   
   
 
Assembly Version: 17.3.0.14 
Installation Directions :  
This patch should replace the files “Syncfusion.Xamarin.XForms.dll”, 
“Syncfusion.SfPdfViewer.XForms.iOS.dll”,“Syncfusion.SfPdfViewer.XForms.UWP.dll”, “Syncfusion.SfPdfViewer.iOS.dll”,“Syncfusion.SfPdfViewer.Android.dll” under the following folder. 
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.6 
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\9.3.0.61\precompiledassemblies\9.3.0.61\4.0 
 
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies. 
 
Note :  
You can change how you receive bug fixes by navigating to the following link and updating your preferences. 
 
https://www.syncfusion.com/support/directtrac/patches 
 
Disclaimer :  
Please note that we have created this patch for version 17.3.0.14 specifically to resolve the following issue(s) reported in this/the incident(s). 148114 
 
If you have received other patches for the same version for other products, please apply all patches in the order received. 
This fix will be included in our 2019 Volume 4 which will be available in December 2019. 
 
 
 
Also please use the modify the below code snippet in your sample instead of existing code to get your issue resolved 
 
//Do not close the filestream it will be internally disposed of by the SfPdfViewer.
//Remove the following line in the sample.
fileStream.Close();
 
  
//Use this to get the byte array from Json string .
string jsonData = "{\"FirstName\":\"Mike\"}";
byte[] byteArray = Encoding.UTF8.GetBytes(jsonData);
 
 
            
 
 

 
Regards, 
 
Jhansi Priya Ramesh 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon