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. Image for the cookie policy date

Couple of questions about syncfusion pdf library.

I have been tasked to create an application where a user can upload a pdf template with form fields, the system will then detect all the form fields and allow the user to "edit each field". I see that syncfusion has a pdf library that can detect form fields and allow to customize the appearance of a form field.

  1. Does syncfusion have any limitations on the uploaded pdf template file or are all pdf template files supported?
  2. Does the syncfusion pdf library have an event that allow user to customize the appearance of a form control?

Please advise.

screenshot-app.useanvil.com-2023.03.04-12_39_48-min.png


11 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team March 6, 2023 02:32 PM UTC

Does syncfusion have any limitations on the uploaded pdf template file or are all pdf template files supported?

All the pdf template supports expect dynamic XFA forms.

 

Please find the below links for more information:

https://help.syncfusion.com/file-formats/pdf/open-and-save-pdf-file-in-c-sharp-vb-net

Does the syncfusion pdf library have an event that allow user to customize the appearance of a form control?

We can modify the form fields supported entries and it will create an appearance based on the changes. We can only customize the signature field appearances externally.

 

Please find the below link for more information,

https://help.syncfusion.com/file-formats/pdf/working-with-forms#set-appearance-to-the-pdf-form-fields

 

https://www.syncfusion.com/kb/9468/how-to-create-the-pdf-digital-signature-with-custom-appearance-in-c-and-vb-net

 

 

//Load the PDF document.

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);

//Get the loaded form.

PdfLoadedForm loadedForm = loadedDocument.Form;

//Set the default appearance.

loadedForm.SetDefaultAppearance(false);

 

//Get the loaded form field.

PdfLoadedTextBoxField loadedTextBoxField = loadedForm.Fields[0] as PdfLoadedTextBoxField;

loadedTextBoxField.Text = "Text";

 

//Save the document.

loadedDocument.Save("Form.pdf");

//Close the document.

loadedDocument.Close(true);



AG ajit goel March 6, 2023 10:29 PM UTC

I am not sure i understand, my question was how would I show the pdf form template and allow user to edit the template by allowing him to specify the data(appearance, data element for each field etc) for each of the form fields(as in the attached screenshot)? Would the pdf viewer control allow me to do that or is this something that I would need to build(and how would I build it, since I dont see any event that I can use when the user navigates into a pdf form element and allow to specify the appearance of the control)? The example that you have shared does all of this at runtime.



VV Visvesvar Venkatesan Syncfusion Team March 8, 2023 02:06 PM UTC

The below sample demonstrates the creation of the supported Form fields in the PDF Viewer such as Textbox, Password, Checkbox, Radio Button, Drop Down, List box, Signature, and Initial. We can also customize these fields and can include new fields through user interaction by switching to the designer mode.


We have provided the online sample and UG documentation for the Form designer below.


Online Sample: https://ej2.syncfusion.com/aspnetcore/PdfViewer/FormDesigner#/fluent


UG Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/form-designer/create-fillable-pdf-forms/create-programmatically


Kindly refer to this and try to achieve your requirement and revert to us if you have any concerns.



AG ajit goel March 9, 2023 05:03 AM UTC


https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/form-designer/create-fillable-pdf-forms/create-programmatically#editupdate-form-field-programmatically  => shows that we can change the background color of the field.

  1. What the different properties that are supported?
  2. How can I get the existing properties of a existing form field? 


pdfviewer.formDesignerModule.updateFormField(pdfviewer.formFieldCollections[0],
            { backgroundColor: 'red' });


VV Visvesvar Venkatesan Syncfusion Team March 10, 2023 11:42 AM UTC

Kindly find the response.


Query

Response

https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/form-designer/create-fillable-pdf-forms/create-programmatically#editupdate-form-field-programmatically  => shows that we can change the background color of the field.

  1. What the different properties that are supported?

 

You can change the colour of the form field programatically using the below code Snippet.

 

Code Snippet:

 

 

      function formFieldUpdate() {

        var viewer = document.getElementById('pdfviewer').ej2_instances[0];

        var formField = viewer.retrieveFormFields();

        for (var i = 0; i < formField.length; i++) {

        viewer.formDesigner.updateFormField(formField[i], {

        visibility: 'visible',

        backgroundColor: 'red',

        });

        }

    }

 

All the properties are available in the viewer.formFieldCollection method.

 

  1. How can I get the existing properties of a existing form field? 

 

You can get the properties for form field in the form field collection method while loading the document in the document load method.

 

Kindly find the code snippet below.

 

Code Snippet:

 

function documentLoad(args) {

         var viewer = document.getElementById('pdfviewer').ej2_instances[0];

          console.log(viewer.formFieldCollection[0]);

         console.log(viewer.formFieldCollection);

 

    }

 

 

 

 

 



Kindly find the sample for the above statements - https://www.syncfusion.com/downloads/support/directtrac/general/ze/ASPNET~3725093867.zip




AG ajit goel March 16, 2023 03:23 AM UTC

I ran the above sample and it threw a "The type initializer for 'Syncfusion.EJ2.PdfViewer.PdfiumNative' threw an exception." error when it calls the https://localhost:5001/api/PdfViewer/Load endpoint. Here's a video: https://youtu.be/Vtvl-Tm9PNw


Please advise.



VV Visvesvar Venkatesan Syncfusion Team March 20, 2023 11:20 AM UTC

We were able to run the sample provided by you and load the document in the sample.


We have attached the video below of loading the document in the sample.


Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Document_sample691616359.zip


Queries:


  • We need to know in which environment you are using whether the “Windows” or “Linux” environment.
  • We also need to know which .NET framework you are using.


To resolve the PDFium exception we have provided the documentation below.


Resolve: https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/how-to/resolve-pdfium-issue


Kindly try this and let us know if you have any concerns.



AG ajit goel March 21, 2023 07:02 AM UTC

I am using .Net 7 and ubuntu OS, and Rider(instead of visual studio).

I am still getting the same error as before. I did add the libpdfium.so file into the root and changed the pdfviewercontroller=>load method like this:

public IActionResult Load([FromBody] Dictionary<string, string> jsonObject)

        {

            Console.WriteLine("Load called");

            PdfRenderer.ReferencePath = _hostingEnvironment.ContentRootPath;

            PdfRenderer pdfviewer = new PdfRenderer(_cache);





VV Visvesvar Venkatesan Syncfusion Team March 22, 2023 03:19 PM UTC

We need to know whether you have installed the PDFium dependency packages are installed in your ubuntu environment.


Step 1: Install the dotnet framework for running the WSL (Windows Subsystem for Linux) in the project by running the following code one by one. 
 

    wget https://packages.microsoft.com/config/ubuntu/22.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

 

    sudo dpkg -i packages-microsoft-prod.deb

 

    rm packages-microsoft-prod.deb

 

    sudo apt-get update && \

    sudo apt-get install -y dotnet-sdk-6.0

 


Check the comment dotnet –info and it should come as follows.

Create-new-blazor-wsl-app



If the above result is not shown, please run the comments below



sudo apt remove dotnet*

 sudo apt remove aspnetcore*

sudo apt remove netstandard*

sudo apt-get remove dotnet-host

sudo apt autoremove

 sudo apt autoremove -y dotnet-sdk-6.0

sudo apt-get update

 dotnet

sudo apt-get install -y dotnet-sdk-6.0

 dotnet

dotnet --info

 



Step 2: Run the sample in WSL (Windows Subsystem for Linux) mode and it will run our PDF Viewer.


NOTE: If you encounter any issues while running in WSL (Windows Subsystem for Linux) mode, use the following instructions to resolve them.

If the sample does not load the PDF file and throws an exception.


To resolve the issue, use the following codes to install the dependencies required for our PDF Viewer to run.


Open the Ubuntu comment window and type the following comments.


sudo cp -u /lib/x86_64-linux-gnu/libdl.so.4 /lib/x86_64-linux-gnu/libdl.so


Then, in the Ubuntu command window, run the following commands one by one to install all necessary PDF Viewer dependencies for a Linux run.


    sudo apt-get install libfontconfig1

    sudo apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev

    sudo apt-get update

    sudo apt install libgdiplus

 


Kindly follow the step 3 and step 4  in the documentation for installing the PDFium nuget.


Documentation: https://blazor.syncfusion.com/documentation/pdfviewer/getting-started/wsl-application



AG ajit goel April 6, 2023 04:44 AM UTC

Based on the instructions at https://www.syncfusion.com/forums/180906/couple-of-questions-about-syncfusion-pdf-library I have added the following instructions to my Dockerfile and both the highlighted lines does not work(The application works if I remove the highlighted lines)

wrt to "Does the syncfusion pdf library have an event that allow user to customize the appearance of a form control?", the event to use is FormFieldClick event, see https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_FormFieldClick

This ticket can be closed.


FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
RUN cp -u /lib/x86_64-linux-gnu/libdl.so.4 /lib/x86_64-linux-gnu/libdl.so
RUN apt-get install libfontconfig1
RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev && apt-get update && apt install libgdiplus
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["EditPDFFormFields/EditPDFFormFields.csproj", "EditPDFFormFields/"]
RUN dotnet restore "EditPDFFormFields/EditPDFFormFields.csproj"
COPY . .
WORKDIR "/src/EditPDFFormFields"
RUN dotnet build "EditPDFFormFields.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "EditPDFFormFields.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "EditPDFFormFields.dll"]


VV Visvesvar Venkatesan Syncfusion Team April 10, 2023 06:52 AM UTC

Thank you for your update. We are closing this forum.


Loader.
Up arrow icon