[PDF Form Filling] The custom formatting is not applied.
Syncfusion.Pdf.Net.Core Version="18.4.0.44"
After filling in fields with PdfLoadedDocument, field formatting is not applied. But when I fill in the fields with Acrobat Writer, everything works perfectly.
In addition, the calculated [Sum] fields do not run automatically
Is there any solution to this problem?
Code Snippit
// ........ using var loadedDocument = new PdfLoadedDocument(sourceStream); var loadedForm = loadedDocument.Form; loadedForm.EnableXfaFormFill = true; loadedForm.DisableAutoFormat = false; // Or true also do not affect
// ........
PdfLoadedDocument:
Adobe Acrobat DC
SIGN IN To post a reply.
15 Replies
1 reply marked as answer
SL
Sowmiya Loganathan
Syncfusion Team
March 1, 2021 02:09 PM UTC
Hi Tarek,
Thank you for contacting Syncfusion support.
We have analyzed the reported issue. Could you please provide us the below details, it will helpful for us to provide the precise solution on this.
- Input document
- Output document
- Product version
Please let us know if you have any concerns on this.
Regards,
Sowmiya Loganathan
TN
Tarek Najem
March 1, 2021 09:54 PM UTC
First I would like to thank you for your interest.
You will find the required files in the attachments, and I will write the code that generate this file.
I used this version: Syncfusion.Pdf.Net.Core Version="18.4.0.44"
SyncfusionPdf.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net5.0</TargetFramework> <LangVersion>latest</LangVersion> <AnalysisLevel>latest</AnalysisLevel> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> </PropertyGroup> <PropertyGroup> <OutputPath>..\..\output</OutputPath> </PropertyGroup> <ItemGroup> <PackageReference Include="Syncfusion.Pdf.Net.Core" Version="18.4.0.44" /> <!--<PackageReference Include="Syncfusion.Pdf.WinForms" Version="18.4.0.44" />--> <PackageReference Include="System.Drawing.Common" Version="5.0.1" /> </ItemGroup> </Project>
using System; using System.Globalization; using System.IO; using System.Reflection; using Syncfusion.Pdf.Parsing; namespace SyncfusionPdf { internal static class Program { private static readonly CultureInfo _cultureInfo = new CultureInfo("nl-NL"); private static void Main() { var startupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var sourceSjabloonPath = Path.Join(startupPath, "Netto-inkomen (A).pdf"); using var sourceSjablonenStream = File.Open(sourceSjabloonPath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read); var loadedDocument = new PdfLoadedDocument(sourceSjablonenStream); var loadedForm = loadedDocument.Form; loadedForm.EnableXfaFormFill = true; loadedForm.DisableAutoFormat = false; // Or true also do not affect loadedForm.SetDefaultAppearance(false); foreach (PdfLoadedField field in loadedForm.Fields) { Console.WriteLine($"{{Type: {field.GetType().Name}, Name: {field.Name.Trim()}, ObjectID: {field.ObjectID}}}"); switch (field) { case PdfLoadedTextBoxField pdfLoadedTextBoxField when pdfLoadedTextBoxField.Name != "A": pdfLoadedTextBoxField.Text = 5.22M.ToString("C2", _cultureInfo); break; } } var targetSjabloonPath = Path.Join(startupPath, $"{Guid.NewGuid()}.pdf"); using var targetSjablonenStream = File.Open(targetSjabloonPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); loadedDocument.Save(targetSjablonenStream); loadedDocument.Close(true); sourceSjablonenStream.Close(); targetSjablonenStream.Flush(); targetSjablonenStream.Close(); } } }
Regards,
Tarek Najem
Attachment: output_input_PDF_f49d7c9e.zip
SL
Sowmiya Loganathan
Syncfusion Team
March 2, 2021 01:46 PM UTC
Hi Tarek,
Thank you for the details.
We have modified the sample to achieve your requirement using the below ways,
· Custom formatting – While setting SetDefaultAppearance to true, the respective values are preserved fine.
· Calculate sum value automatically – we do not have support to calculate the sum value automatically. However, we can achieve this as manually.
Please refer the below code snippet for more details,
|
//Load PDF document
FileStream docStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
var loadedForm = loadedDocument.Form;
float total = 0;
loadedForm.EnableXfaFormFill = true;
loadedForm.DisableAutoFormat = false;
loadedForm.SetDefaultAppearance(true);
foreach (PdfLoadedField field in loadedForm.Fields)
{
Console.WriteLine($"{{Type: {field.GetType().Name}, Name: {field.Name.Trim()}, ObjectID:{field.ObjectID}}}");
switch (field)
{
case PdfLoadedTextBoxField pdfLoadedTextBoxField whenpdfLoadedTextBoxField.Name != "A":
pdfLoadedTextBoxField.Text = 5.22M.ToString("C2", _cultureInfo);
total += 5.22f;
break;
case PdfLoadedTextBoxField pdfLoadedTextBoxField whenpdfLoadedTextBoxField.Name == "A":
pdfLoadedTextBoxField.Text = total.ToString("C2", _cultureInfo);
break;
}
}
//Save and close the document
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream);
loadedDocument.Close(true);
|
Please try the above sample in your end and let us know the result.
Regards,
Sowmiya Loganathan
TN
Tarek Najem
March 2, 2021 02:18 PM UTC
First, I want to thank you for your interest.
The error is still present in version: Syncfusion.Pdf.Net.Core 18.4.0.44.
But it works fine with this version: Syncfusion.Pdf.Net.Core 17.1.0.52.
However, the problem of the calculated fields was not solved in the old version or the new version.
I expect you to solve this problem in the near future version.
Regards,
T. Najem
GK
Gowthamraj Kumar
Syncfusion Team
March 3, 2021 04:59 PM UTC
Hi Tarek,
Thank you for sharing the details,
Currently, we are trying to reproduce the issue with provided details on our end and we will update the further details on March 4th 2021.
Regards,
Gowthamraj K
TN
Tarek Najem
March 3, 2021 07:27 PM UTC
In short, the formatting assigned to the field or SUM is not applied. If you go back to your example and make the number greater than a thousand, you will have another problem.
In the end, I will now make two copies, a copy to be filled out automatically, and the copy that contains the formatting, I will make it manually for the user to fill in.
This means that our program has failed.
Thank you for your cooperation in advance.
Regards,
GK
Gowthamraj Kumar
Syncfusion Team
March 4, 2021 06:55 PM UTC
Hi Tarek,
Thank you for your update.
We were able to reproduce the reported rendering issue with provided details on our end. Currently, we are validating on this issue with your scenarios and we will update the further details on March 8th, 2021
Regards,
Gowthamraj K
TN
Tarek Najem
March 4, 2021 08:24 PM UTC
Dear Syncfusion Team,
I am very happy to hear the good news that you will soon develop the product with this scenario in mind.
Regards,
Tarek Najem,
GK
Gowthamraj Kumar
Syncfusion Team
March 5, 2021 11:55 AM UTC
Hi Tarek,
Thank you for your patience.
As we said earlier, we are validating on this issue with your scenarios and we will update the further details on March 8th, 2021
Regards,
Gowthamraj K
GK
Gowthamraj Kumar
Syncfusion Team
March 8, 2021 01:36 PM UTC
Hi Tarek,
Thank you for your patience.
We have recently resolved a similar issue and the fix is included in our upcoming 2021 volume 1 main release which will be available in mid of March 2021 tentatively.
Note: We could not able to provide the patch in the product version 18.4.0.44 since it is a weekly NuGet release. So please share us the product version which you need the patch, so that we will update the patch in the same version.
Regards,
Gowthamraj K
TN
Tarek Najem
March 8, 2021 03:50 PM UTC
Hallo Gowthamraj,
First of all, I would like to thank you for the fast communication and solutions.
This is the version I am using now:
Syncfusion.Pdf.Net.Core: 18.4.0.46
Regards,
T. Najem
GK
Gowthamraj Kumar
Syncfusion Team
March 9, 2021 10:53 AM UTC
Hi Tarek,
Thank you for your update.
The provided product version (18.4.0.46) is also the weekly NuGet release version. We could not able to provide the patch in the product version 18.4.0.46. The reported fix is included in our upcoming 2021 volume 1 main release which will be available in mid of March 2021 tentatively.
Regards,
Gowthamraj K
TN
Tarek Najem
March 9, 2021 03:00 PM UTC
Thank you very much,
If you can tell me the version number that you can apply this update to, with the update link.
So that we can test this update and provide you with feedback about
For now, I can wait.
Regards,
Tarek Najem
GK
Gowthamraj Kumar
Syncfusion Team
March 10, 2021 09:32 AM UTC
Hi Tarek,
Thank you for your patience.
As we said earlier, the fix is included in our upcoming 2021 volume 1 main release which we excepted on mid of March 2021 tentatively.
Note: Release version and link details will be update later, once its rolled out.
Regards,
Gowthamraj K
GK
Gowthamraj Kumar
Syncfusion Team
March 31, 2021 03:22 PM UTC
Hi Tarek,
Thank you for your patience.
We have included the fix for the reported issue in our Essential Studio 2021 Volume 1 main release v19.1.0.54.
We are glad to announce that our Essential Studio 2021 Volume 1 Main release v19.1.0.54 is rolled out and is available for download under the following link.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Gowthamraj K
Marked as answer
SIGN IN To post a reply.
- 15 Replies
- 3 Participants
- Marked answer
-
TN Tarek Najem
- Feb 26, 2021 05:37 AM UTC
- Mar 31, 2021 03:22 PM UTC