- Check Input PDF Files: Files are not corrupted and ok. I have send you 2 example files (see 1.pdf and 2.pdf).
1.pdf (314.0 KB)
2.pdf (5.3 MB)
-
Update Aspose.PDF Library: i am using the latest version of the Aspose.PDF library 25.1.
-
Use Conversion Logs: When converting, i am generating a log file but the content is in both cases empty.
xml report of 1.pdf and 2.pdf.jpg (70.8 KB)
-
Validation Before Conversion: i have also validated the pdf before converting and get still the same error while converting: {“The given key was not present in the dictionary.”} and {“Object reference not set to an instance of an object.”}
var doc = new Document(org_doc.FullPath);
bool isValidated = doc.Validate(new MemoryStream(), settings.PdfSaveSettings.PdfFormat);
doc.Convert($"{org_doc.OutPutPath}_report.xml", PdfFormat.PDF_A_2A, ConvertErrorAction.Delete);// settings.PdfSaveSettings.PdfFormat, settings.PdfASaveSettings.ErrorAction);
var temp_doc = org_doc.OutPutPath + "\\" + org_doc.Name + ".pdf" ;
doc.Save(temp_doc);
- Error Handling:
for the file “1.pdf” i have the following detailed log:
2025-02-10 16:04:21,091 [1] [ERROR] in [Logic.AsposeToPDF] at [ConvertDirectPathToPDFA:63] - System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.SortedDictionary`2.get_Item(TKey key)
at #=zHOP4jYW663h2yJcSU1a$nd6ndY4Jm7ZRc5a0FywCncbfpAXABTMU3qf3BUxxCW0mRg==.#=zmcP6giPsrtKB4SxiUA==(#=z6sKYofmDB6xq0Pu9RFKhwltyE8WNejA1bVZQ86GVya9SOm8n3Q== #=zyHZ7nZ66w9zU, Dictionary`2 #=zF9bwZeJjVob0)
at #=zHOP4jYW663h2yJcSU1a$nd6ndY4Jm7ZRc5a0FywCncbfpAXABTMU3qf3BUxxCW0mRg==.#=zaUUPCvlftWri()
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zxVHN0vweR9y5(#=znIyrmYK9qV1JPRJH26DwKvwtiNRu$MJZuEEbGyaWVgxUnUYXZg== #=zs3JmJ9Q=, #=zf1bKw0bATPBO_bsQ69Y1z_Hy5DCeuh6u_fXz97_epg_zVkFNSA== #=zzFPX55WQRxuZ)
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zgG6ojFg=()
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=z6CafyS8=()
at #=zgEtn9w7Ein38ugMGL6hgannB6dBsDOhkz1YC6C17gzKZxeLJEuyT7lA=.#=zGb7u3Rw=()
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zcpDqTq8=(XmlTextWriter #=znddg2oY=, PdfFormat #=zdbpOXPY=, Document #=zw62GAq4=, Boolean #=zxl5yfDZwUewC, ConvertErrorAction #=z9jCEnLI=)
at Aspose.Pdf.Document.#=zzFxYPrY=(XmlTextWriter #=znddg2oY=, PdfFormat #=zdbpOXPY=, Boolean #=zxl5yfDZwUewC, ConvertErrorAction #=z9jCEnLI=, ConvertTransparencyAction #=z59UXlZ$45k7K4jHXjTOmKeM=)
at Aspose.Pdf.Document.Convert(String outputLogFileName, PdfFormat format, ConvertErrorAction action, ConvertTransparencyAction transparencyAction)
at Aspose.Pdf.Document.Convert(String outputLogFileName, PdfFormat format, ConvertErrorAction action)
at ACPDF.Logic.AsposeToPDF.ConvertDirectPathToPDFA(BaseDocument org_doc, AsposeSettings settings) in C:\Users\labadmin\Development\Aspose\Aspose.Converter.PdfToPdfA\ACPDF\Logic\AsposeToPDF.cs:line 32
2025-02-10 16:04:27,890 [1] [INFO ] in [ACPDF.RunConvert] at [Main:95] - Error=> File Name: 1.pdf -Message: ConvertToPDF was not successful -Time: 9 seconds.
for the file “2.pdf” i have the following detailed log:
2025-02-10 16:04:30,138 [1] [ERROR] in [Logic.AsposeToPDF] at [ConvertDirectPathToPDFA:63] - System.NullReferenceException: Object reference not set to an instance of an object.
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zNWpu1K_K_PwV(Page #=zlKmJpsA=, OperatorCollection #=zYNs5CcE=, Resources #=z9URQ63o=, Int32 #=zjZTbOT8JHlbl, #=zf1bKw0bATPBO_bsQ69Y1z_Hy5DCeuh6u_fXz97_epg_zVkFNSA== #=zzFPX55WQRxuZ)
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zJgsi88c_GMWu(Page #=zlKmJpsA=, #=zf1bKw0bATPBO_bsQ69Y1z_Hy5DCeuh6u_fXz97_epg_zVkFNSA== #=zzFPX55WQRxuZ)
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zgG6ojFg=()
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=z6CafyS8=()
at #=zgEtn9w7Ein38ugMGL6hgannB6dBsDOhkz1YC6C17gzKZxeLJEuyT7lA=.#=zGb7u3Rw=()
at #=zG_hZ0KFVOd$Vu0VgoDB6Il6eB7JJIw2J85_MdqlrfqfjdLpzv5z_$C0=.#=zcpDqTq8=(XmlTextWriter #=znddg2oY=, PdfFormat #=zdbpOXPY=, Document #=zw62GAq4=, Boolean #=zxl5yfDZwUewC, ConvertErrorAction #=z9jCEnLI=)
at Aspose.Pdf.Document.#=zzFxYPrY=(XmlTextWriter #=znddg2oY=, PdfFormat #=zdbpOXPY=, Boolean #=zxl5yfDZwUewC, ConvertErrorAction #=z9jCEnLI=)
at Aspose.Pdf.Document.Validate(Stream outputLogStream, PdfFormat format)
at ACPDF.Logic.AsposeToPDF.ConvertDirectPathToPDFA(BaseDocument org_doc, AsposeSettings settings) in C:\Users\labadmin\Development\Aspose\Aspose.Converter.PdfToPdfA\ACPDF\Logic\AsposeToPDF.cs:line 31
2025-02-10 16:04:30,140 [1] [INFO ] in [ACPDF.RunConvert] at [Main:95] - Error=> File Name: 2.pdf -Message: ConvertToPDF was not successful -Time: 1 seconds.
- Sample Code for Conversion: i use the same code as you mentioned and still getting error.
Consult Documentation: i have read the documentation and there is nothing special about these pdf’s or the method.
thanks in advance for anay help