Tadelsucht / BulkPDF

BulkPDF is a free and easy to use open source software, which allows to automatically fill an existing PDF form with differen values. Only a spreadsheet (Microsoft Excel 2007/2010/2013, LibreOffice or OpenOffice Calc) with the desired values is required.
http://bulkpdf.de
GNU Affero General Public License v3.0
127 stars 36 forks source link

System.FormatException when trying to create PDFs. #6

Closed gitty4 closed 6 years ago

gitty4 commented 7 years ago

Even with the example sheet and the example PDF with the configuration

I get the error

One or more PDF files with the selected name already exists and is use by another application. Please close the other application and restart the creation process.

thrown with

System.FormatException: Die Eingabezeichenfolge hat das falsche Format.
   bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   bei System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   bei iTextSharp.text.pdf.Type1Font.Process(RandomAccessFileOrArray rf)
   bei iTextSharp.text.pdf.Type1Font..ctor(String afmFile, String enc, Boolean emb, Byte[] ttfAfm, Byte[] pfb, Boolean forceRead)
   bei iTextSharp.text.pdf.BaseFont.CreateFont(String name, String encoding, Boolean embedded, Boolean cached, Byte[] ttfAfm, Byte[] pfb, Boolean noThrow, Boolean forceRead)
   bei iTextSharp.text.pdf.BaseFont.CreateFont(String name, String encoding, Boolean embedded)
   bei iTextSharp.text.pdf.DocumentFont.DoType1TT()
   bei iTextSharp.text.pdf.DocumentFont..ctor(PRIndirectReference refFont, PdfDictionary drEncoding)
   bei iTextSharp.text.pdf.AcroFields.DecodeGenericDictionary(PdfDictionary merged, BaseField tx)
   bei iTextSharp.text.pdf.AcroFields.GetAppearance(PdfDictionary merged, String[] values, String fieldName)
   bei iTextSharp.text.pdf.AcroFields.SetField(String name, String value, String display, Boolean saveAppearance)
   bei iTextSharp.text.pdf.AcroFields.SetField(String name, String value, Boolean saveAppearance)
   bei BulkPDF.PDF.SaveFilledPDF(String filePath, Boolean finalize)
   bei BulkPDF.PDFFiller.CreateFiles(PDF pdf, Boolean finalize, IDataSource dataSource, Dictionary`2 pdfFields, String outputDir, DelGetFilename GetFilename, DelSetPercent setPercent, DelIsAborted isAborted)
   bei BulkPDF.MainForm.backGroundWorker_DoWork(Object sender, DoWorkEventArgs e)

I am using the latest zip/portable version v1.0.2.0.

Tadelsucht commented 7 years ago

For me this configuration works. Could please save your configuration and provide the ".bulkpdf" file here. It would be useful for debugging.

save_config

gitty4 commented 7 years ago

The BulkPDF folder is in D:\ and the configuration is saved as the following file (I added .txt because GitHub doesn't allow .bulkpdf files):

example.bulkpdf

There doesn't seem to be anything out of the ordinary …

I can only guess that the problem has something to do with the portable/zip version or with my company's computer (also the reason against a proper installation) or a combination of both?

Tadelsucht commented 7 years ago

The portable version is the same as the installer. I had just wrapped a installer around. It still works for me, even if I use another drive than "C:".

The problem seems to be occure in the following class of the iTextSharp library I use. https://github.com/WolfeReiter/iTextSharp/blob/master/iTextSharp/text/pdf/Type1Font.cs#L324 After the look at the library class, I would say that maybe something block BulkPDF to read/write the pdf file on the drive. Maybe a corporate anti virus program? Please test the program on another PC. At best at home with advanced rights.

Also you could try to use the attached newest version of the library. Just overwrite the two files in the bulkpdf with the newer once in the zip. itextsharp_5_5_10_dll.zip

gitty4 commented 7 years ago

The portable version is the same as the installer. I had just wrapped a installer around. It still works for me, even if I use another drive than "C:".

I wouldn't believe it had something to do with that.

After the look at the library class, I would say that maybe something block BulkPDF to read/write the pdf file on the drive. Maybe a corporate anti virus program?

But why the Number.FormatException? It is a good guess, though. However, I can't find anything in the logs of the anti-virus program that suggests that it's blocking anything.

Please test the program on another PC. At best at home with advanced rights.

I'm not doubting that it doesn't work. :)

Also you could try to use the attached newest version of the library. Just overwrite the two files in the bulkpdf with the newer once in the zip.

I tried that. Now, loading the PDF results in a message stating

PDF-Datei scheint beschädigt zu sein. [\]

and the following exception

System.IO.FileLoadException: Die Datei oder Assembly "itextsharp, Version=5.5.7.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
Dateiname: "itextsharp, Version=5.5.7.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca"
   bei BulkPDF.PDF.Open(String filePath)
   bei BulkPDF.MainForm.OpenPDF(String pdfPath)

WRN: Protokollierung der Assemblybindung ist AUS.
Sie können die Protokollierung der Assemblybindungsfehler aktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) auf 1 festlegen.
Hinweis: Die Protokollierung der Assemblybindungsfehler führt zu einer gewissen Leistungseinbuße.
Sie können dieses Feature deaktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] entfernen.

I'd try compiling and debugging the source myself, but again, I can't on this troublesome PC.

Tadelsucht commented 7 years ago

But why the Number.FormatException?

I'm not sure about that anymore.. The "rf.ReadLine()" in the third line in the "Process()" method, which will execute the "read()" method of the "RandomAccessFileOrArray" class. In this method it will read from the rf filestream, which is created in the constructor and use the selected pdf form. It seems to read successfully the "metric"-while-block in the "Process()" method but in the second while-block it must fail at ident.Equals("C") or ident.Equals("B").

Do you found out something new while debugging?

I tried that. Now, loading the PDF results in a message stating

Sorry. I didn't tested if it works when the DLL file is simply changed.