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.
Please advise.
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,
|
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.
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.
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.
pdfviewer.formDesignerModule.updateFormField(pdfviewer.formFieldCollections[0],
{ backgroundColor: 'red' });
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.
|
You can change the colour of the form field programatically using the below code Snippet.
Code Snippet:
All the properties are available in the viewer.formFieldCollection method.
|
|
|
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:
|
Kindly find the sample for the above statements - https://www.syncfusion.com/downloads/support/directtrac/general/ze/ASPNET~3725093867.zip
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.
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:
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.
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);
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.
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
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.
Thank you for your update. We are closing this forum.