Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Aug 06, 2021 4:10 pm

Sans titre.png
When i try to merge pdf with the new methode of merge (I copy past the code in the tuto), i have format error issu depending on the language selected in my regional setting. When i put it in french it doesn't work but in english everything is fine.

Il reproduce the error on different machine and i use the la nugget version. You can see in attachment an image of the windows setting causing problem.

In addition, i have form on that PDF, (I put pdf exemple to merge in attachment). The Form on different PDF contain field with the same name but when i merge sucessfully, the name are changed, but i want to keep the name similare because the field with the same name should contain the same information.

Have you a work a round to keep the same name on the pdf ?

Tanks.

boucharo
 
Posts: 7
Joined: Fri Nov 03, 2017 3:38 pm
Location: Quebec, Canada

Sun Aug 08, 2021 5:05 pm

Here is information about the exception i get. I use this code :

Dim log As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("D:\Bureau\Lab\spirePDf\log.txt", False)
For Each file As String In IO.Directory.GetFiles("D:\Bureau\Lab\spirePDf")
If Not file.ToLower.Trim.EndsWith(".pdf") Then Continue For
Try
Dim files As String() = New String() {file}

Dim outputFile As String = "D:\Bureau\Lab\spirePDf\result\result-" & IO.Path.GetFileNameWithoutExtension(file) & ".pdf"

Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files)

doc.Save(outputFile, FileFormat.PDF)
Catch ex As Exception
log.WriteLine(file)
End Try

Next


log.Close()
The errore detail :

- $exception {"Le format de la chaîne d'entrée est incorrect."} System.FormatException

à System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
à Spire.Pdf.Widget.PdfStyledFieldWidget.ᜀ(String[] A_0)
à Spire.Pdf.Widget.PdfStyledFieldWidget.get_Font()
à Spire.Pdf.Widget.PdfFieldWidgetItem.ᜍ()
à Spire.Pdf.Widget.PdfStyledFieldWidget.GraphicsProperties..ctor(PdfFieldWidgetItem widgetItem)
à Spire.Pdf.Widget.PdfStyledFieldWidget.GetGraphicsProperties(GraphicsProperties& graphicsProperties, PdfFieldWidgetItem widgetItem)
à Spire.Pdf.Widget.PdfTextBoxFieldWidget.ᜀ(PdfCanvas A_0, PdfFieldWidgetItem A_1)
à Spire.Pdf.Widget.PdfTextBoxFieldWidget.ᜀ(sprឝ A_0, PdfFieldWidgetItem A_1)
à Spire.Pdf.Widget.PdfTextBoxFieldWidget.BeginSave()
à Spire.Pdf.Fields.PdfForm.ᜀ()
à Spire.Pdf.Fields.PdfForm.Dictionary_BeginSave(Object sender, sprស ars)
à sprឝ.ᜀ(sprស A_0)
à sprឝ.ᜀ(spr᝷ A_0, Boolean A_1)
à sprឝ.ᜅ(spr᝷ A_0)
à spr᠞.ᜀ(spr᝵ A_0, sprឤ A_1)
à spr᠟.ᜁ(spr᝵ A_0, sprឤ A_1, sprᠨ A_2)
à spr᠟.ᜀ(spr᝵ A_0, sprᠨ A_1)
à spr᠟.ᜄ(sprᠨ A_0)
à spr᠟.ᜅ(sprᠨ A_0)
à Spire.Pdf.PdfNewDocument.Save(Stream stream)
à Spire.Pdf.PdfDocumentBase.Save(String filename)
à Spire.Pdf.PdfDocumentBase.Save(String fileName, FileFormat fileformat)
à ShowFormProjet.Form1.Button4_Click(Object sender, EventArgs e)

boucharo
 
Posts: 7
Joined: Fri Nov 03, 2017 3:38 pm
Location: Quebec, Canada

Sun Aug 08, 2021 5:14 pm

I finally found a workAround : If it's interest someone :

But if you can fix it it would be appreciate.

Tanks

Here's the workArround :
Dim tempCulti As CultureInfo = Thread.CurrentThread.CurrentCulture

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-EN")

Dim log As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("D:\Bureau\Lab\spirePDf\log.txt", False)

Dim last As String = "D:\Bureau\Lab\spirePDf\result\41-525 - Copie.pdf"
For Each file As String In IO.Directory.GetFiles("D:\Bureau\Lab\spirePDf")
If Not file.ToLower.Trim.EndsWith(".pdf") Then Continue For
Try

Dim files As String() = New String() {file, last}

Dim outputFile As String = "D:\Bureau\Lab\spirePDf\result\result-" & IO.Path.GetFileNameWithoutExtension(file) & ".pdf"

Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files)

doc.Save(outputFile, FileFormat.PDF)
Catch ex As Exception
log.WriteLine(file)
End Try
last = file
Next


log.Close()


Thread.CurrentThread.CurrentCulture = tempCulti

boucharo
 
Posts: 7
Joined: Fri Nov 03, 2017 3:38 pm
Location: Quebec, Canada

Mon Aug 09, 2021 9:36 am

Hello,

Thanks for your inquiry.

Under French (Canada) regional settings, I did reproduce the issue that the program throws an exception when merging PDF files. I have logged this issue in our bug tracking system with the ticket SPIREPDF-4540.
As for the name of the form with the same name was changed after merging PDF files, I also reproduced this issue and logged it in our bug tracking system with the ticket SPIREPDF-4541.

If there is any update, we will let you know. Apologize for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Aug 20, 2021 12:19 pm

Hello,

Greetings from E-icblue!
Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:7.8.8 which fixed the issue SPIREPDF-4540, please download it from the following links to test on your side. Looking forward to your test result.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/7.8.8

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Sat Oct 09, 2021 10:03 am

Hello,

Greetings from E-icblue!
Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:7.10.0 which fixed the issue SPIREPDF-4541, please download it from the following links to test on your side. Looking forward to your test result.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/7.10.0
https://www.nuget.org/packages/Spire.PDF.NETCore/7.10.0

Sample code:
Code: Select all
 MergerOptions merger = new MergerOptions();
 merger.SameFieldNameToOneField = true;
PdfMerger.Merge(files, outputFile, merger);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Oct 14, 2021 7:33 am

Hello,

Greetings from E-iceblue!
Does this hotfix work for you? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF