You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my customer has a lot of signed PDFs. These PDFs are signed with Pkcs#7 and have the extension file.pdf.p7m.
PdfPig can load some of these files, but not all.
To support all of them I use the following code:
// if file is p7m:awaitusingvarfs=File.OpenRead(file);varsignedFile=newOrg.BouncyCastle.Cms.CmsSignedData(fs);usingvarms=newMemoryStream();signedFile.SignedContent.Write(ms);ms.Position=0;vardoc=PdfDocument.Open(ms);
Maybe it could be implemented in the lib as many other PDF libs seem to load these files without problems.
**Some Errors `PdfPig` Shows**
PdfP7M:@"\pdf_p7m\Allegato 5 - Criteri valutazione tecnica.pdf.p7m"-System.NullReferenceException: Object reference not set to an instance of an object.
at UglyToad.PdfPig.PdfExtensions.TryGet[T](DictionaryTokendictionary,NameTokenname,IPdfTokenScannertokenScanner,T&token)
at UglyToad.PdfPig.Content.PagesFactory.CheckIfIsPage(DictionaryTokennodeDictionary,IndirectReferenceparentReference,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing)
at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReferencereferenceInput,DictionaryTokennodeDictionaryInput,IndirectReferenceparentReferenceInput,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing,PageCounterpageNumber)
at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReferencepagesReference,DictionaryTokenpagesDictionary,IPdfTokenScannerscanner,IPageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\AMSA. Appalto integrato - Disciplinare di gara 29.06.2022.pdf.p7m"-System.NullReferenceException: Object reference not set to an instance of an object.
at UglyToad.PdfPig.PdfExtensions.TryGet[T](DictionaryTokendictionary,NameTokenname,IPdfTokenScannertokenScanner,T&token)
at UglyToad.PdfPig.Content.PagesFactory.CheckIfIsPage(DictionaryTokennodeDictionary,IndirectReferenceparentReference,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing)
at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReferencereferenceInput,DictionaryTokennodeDictionaryInput,IndirectReferenceparentReferenceInput,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing,PageCounterpageNumber)
at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReferencepagesReference,DictionaryTokenpagesDictionary,IPdfTokenScannerscanner,IPageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\AMSA. Appalto integrato - lettera-di-invito.pdf.p7m"-System.NullReferenceException: Object reference not set to an instance of an object.
at UglyToad.PdfPig.PdfExtensions.TryGet[T](DictionaryTokendictionary,NameTokenname,IPdfTokenScannertokenScanner,T&token)
at UglyToad.PdfPig.Content.PagesFactory.CheckIfIsPage(DictionaryTokennodeDictionary,IndirectReferenceparentReference,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing)
at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReferencereferenceInput,DictionaryTokennodeDictionaryInput,IndirectReferenceparentReferenceInput,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing,PageCounterpageNumber)
at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReferencepagesReference,DictionaryTokenpagesDictionary,IPdfTokenScannerscanner,IPageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\AMSA. Appalto integrato. Capitolato speciale lavori.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The type of the catalog dictionary was not Catalog:<Type,/Cat\x04�\x03�alog>,<Pages,3820>,<PageMode,/UseNone>,<OutputIntents,[5040]>,<Outlines,2070>,<Lang,(en-US)>,<Metadata,1050>.at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\AMSA. Appalto integrato. Capitolato speciale prog. esecutivo.pdf.p7m"-System.NullReferenceException: Object reference not set to an instance of an object.
at UglyToad.PdfPig.PdfExtensions.TryGet[T](DictionaryTokendictionary,NameTokenname,IPdfTokenScannertokenScanner,T&token)
at UglyToad.PdfPig.Content.PagesFactory.CheckIfIsPage(DictionaryTokennodeDictionary,IndirectReferenceparentReference,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing)
at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReferencereferenceInput,DictionaryTokennodeDictionaryInput,IndirectReferenceparentReferenceInput,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing,PageCounterpageNumber)
at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReferencepagesReference,DictionaryTokenpagesDictionary,IPdfTokenScannerscanner,IPageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\PD.D.A.GEN.1040 - RELAZIONE TECNICA IMPIANTI.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The dictionary did not contain a number with the key /Size.Dictionary way:.
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryTokentoken,NameTokenname)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryTokendictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64firstCrossReferenceOffset,Int64offsetCorrection,ILoglog)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytesbytes,BooleanisLenientParsing,Int64crossReferenceLocation,Int64offsetCorrection,IPdfTokenScannerpdfScanner,ISeekableTokenScannertokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\PD.D.A.GEN.1041 - RELAZIONE CONSUMI ENERGETICI - EX LEGGE 10.91 .pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The dictionary did not contain a number with the key /Size.Dictionary way:.
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryTokentoken,NameTokenname)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryTokendictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64firstCrossReferenceOffset,Int64offsetCorrection,ILoglog)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytesbytes,BooleanisLenientParsing,Int64crossReferenceLocation,Int64offsetCorrection,IPdfTokenScannerpdfScanner,ISeekableTokenScannertokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\PD.D.A.GEN.1090 - RELAZIONE AUTORIZZAZIONE ALLO SCARICO.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The dictionary did not contain a number with the key /Size.Dictionary way:.
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryTokentoken,NameTokenname)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryTokendictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64firstCrossReferenceOffset,Int64offsetCorrection,ILoglog)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytesbytes,BooleanisLenientParsing,Int64crossReferenceLocation,Int64offsetCorrection,IPdfTokenScannerpdfScanner,ISeekableTokenScannertokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\PD.GEO.01 RELAZIONE GEOLOGICA GEOTECNICA E DI COMPATIBILITA_.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The dictionary did not contain a number with the key /Size.Dictionary way:.
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryTokentoken,NameTokenname)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryTokendictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64firstCrossReferenceOffset,Int64offsetCorrection,ILoglog)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytesbytes,BooleanisLenientParsing,Int64crossReferenceLocation,Int64offsetCorrection,IPdfTokenScannerpdfScanner,ISeekableTokenScannertokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\PD.GEO.02 ASSEVERAZIONE TIZIANA BAMPI.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: The dictionary did not contain a number with the key /Size.Dictionary way:.
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryTokentoken,NameTokenname)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryTokendictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64firstCrossReferenceOffset,Int64offsetCorrection,ILoglog)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytesbytes,BooleanisLenientParsing,Int64crossReferenceLocation,Int64offsetCorrection,IPdfTokenScannerpdfScanner,ISeekableTokenScannertokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
PdfP7M:@"\pdf_p7m\Relazione def.pdf.p7m"-UglyToad.PdfPig.Core.PdfDocumentFormatException: Could not find dictionary associated with reference in pages kids array:350.
at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReferencereferenceInput,DictionaryTokennodeDictionaryInput,IndirectReferenceparentReferenceInput,BooleanisRoot,IPdfTokenScannerpdfTokenScanner,BooleanisLenientParsing,PageCounterpageNumber)
at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReferencepagesReference,DictionaryTokenpagesDictionary,IPdfTokenScannerscanner,IPageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReferencerootReference,DictionaryTokendictionary,IPdfTokenScannerscanner,PageFactorypageFactory,ILoglog,BooleanisLenientParsing)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytesinputBytes,ISeekableTokenScannerscanner,InternalParsingOptionsparsingOptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytesinputBytes,ParsingOptionsoptions)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Streamstream,ParsingOptionsoptions)
at UglyToad.PdfPig.PdfDocument.Open(Streamstream,ParsingOptionsoptions)
at JurisMatic.Files.Tests.FileDetectorTests.Find_bad_pdf()in C:\Projects\LarchSys\JurisMatic\Libraries\JurisMatic.Files.Tests\FileDetectorTests.cs:line 209
I could send you some of these files on a private channel.
Kind regards
René
The text was updated successfully, but these errors were encountered:
Hi,
my customer has a lot of signed PDFs. These PDFs are signed with Pkcs#7 and have the extension
file.pdf.p7m
.PdfPig can load some of these files, but not all.
To support all of them I use the following code:
Maybe it could be implemented in the lib as many other PDF libs seem to load these files without problems.
**Some Errors `PdfPig` Shows**
I could send you some of these files on a private channel.
Kind regards
René
The text was updated successfully, but these errors were encountered: