Comments (13)
I don't have any RC4 encrypted files to hand to test with, but in case it's of any interest I tried encrypting a trivial PDF with the online tool @ http://www.pdfill.com/pdftool_encrypt.html and the resulting file is opened and identified as RC4 40bit by Acrobat Reader, but reading it with PdfPig throws
UglyToad.PdfPig.Exceptions.PdfDocumentFormatException : The dictionary did not contain a number with the key /Size. Dictionary way: .
Result StackTrace:
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryToken token, NameToken name)
at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryToken dictionary)
at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64 firstCrossReferenceOffset, ILog log)
at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytes bytes, Boolean isLenientParsing, Int64 crossReferenceLocation, IPdfTokenScanner pdfScanner, ISeekableTokenScanner tokenScanner)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, IContainer container, Boolean isLenientParsing, String password)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytes inputBytes, ParsingOptions options)
at UglyToad.PdfPig.PdfDocument.Open(Stream stream, ParsingOptions options)
Sample file:
rc4.pdf
from pdfpig.
Thanks for the feedback, I'll look into adding AES support as the next feature.
I think I've got a couple of documents in my test set which are AES encrypted, do you have any documents you're able to share so I can check it works once I've implemented it?
from pdfpig.
Can you please give the attached nuget package a go and let me know if it works for your files please? I've added support for revision 5 encryption defined in this supplement: https://www.adobe.com/content/dam/acom/en/devnet/flashplayer/pdfs/adobe_supplement_iso32000.pdf
Currently the PDF version 2 specification defines an additional encryption level (revision 6) but the specification is being held hostage by ISO who want a vast amount of money for it, I could port the line by line version of the PDFBox algorithm for that level but I'd rather avoid it if this works.
from pdfpig.
I'm testing it now. I do not have any documents that I can share at this time.
from pdfpig.
I'm getting the error "Support for revision 6 encryption not supported"
from pdfpig.
OK, looks like revision 6 also needs to be implemented, I'll try to get round to it soon.
from pdfpig.
Thanks! I also noticed that I've got a lot of files that encrypted with 40-bit RC4 that don't open either. Is that cipher supported?
from pdfpig.
Hmm, I'm surprised the RC4 doesn't work, do you get a specific error, the details might be in the inner exception?
from pdfpig.
@Numpsy thanks, I didn't think to try using an online tool. I've tried a couple of documents from that site and they seem to have some problems with cross-reference table positions which I've fixed in the last commit, do you remember the password for the file you attached? I just want to check if it had a different problem to the one I think I resolved.
from pdfpig.
ah, sorry, forgot to say - the password should just be 'password'
from pdfpig.
I've found this tool https://www.sejda.com/encrypt-pdf which is capable of producing Revision 6 encrypted documents so can start an implementation soon. I've attached an example file for which the password is maltby
.
from pdfpig.
Sorry for the delay in implementing this. I think it should now be working. Please try the attached package.
If you do encounter errors please try and post as many details as possible, particularly inner exceptions and stack traces.
from pdfpig.
Are you happy to close this issue now? Hopefully the latest 0.0.7 version includes full encryption support but I've not had many documents to test against so just wanted to check if it's ok to close this issue.
from pdfpig.
Related Issues (20)
- PDF Image number zero
- Could not find the startxref within the last 2048 characters. HOT 2
- The given key '/a0' was not present in the dictionary.
- Memory Issues on GetWords() and crashes with given file HOT 2
- EOF problem with file.
- Unable to parse pdf due to font issue
- UnsupervisedReadingOrder orders 2 blocks on the same row out of order HOT 2
- PDF linearization
- When a get textblock from a PDF vary depending on the operating system HOT 6
- New Nuget package release for PDF Pig HOT 4
- XYLeaf.GetLines collect lines not robust enough HOT 18
- Extracting lines HOT 3
- Copy existing page to PdfDocumentBuilder without it's text HOT 1
- TryGetForm does not support field partial names with a "." HOT 5
- Support p7m signed PDFs
- Why GlyphRectangle bounding box not correct for letter g?
- Errors in examples on "readme.md" ? HOT 1
- Allow reading orders dectors to support any class that has a bounding box/PdfRectangle HOT 1
- File exception: UglyToad.PdfPig.Core.PdfDocumentFormatException' was thrown. HOT 4
- ArgumentOutOfRangeException when reading a document HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfpig.