-
-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can pdf_crypto load all kinds of pdf files? #1823
Comments
pdf_crypto doesn't render pdf, it only allow to modify them and add some cryptography. |
@DavBfr I misspoke. I don't need pdf_crypto to render the PDF. I just need to parse it so I can modify it so it can become renderable using other pdf rendering plugins out there. I just want to know if it can parse these PDFs. |
@DavBfr Can I send you some pdfs that you can test if loading with pdf_crypto and then saving them with the pdf plugin works? For example, the pdfs that don't render on iOS become renderable if I simply load and rewrite the pdf with Ghostscript.
https://teikningar.rnb.is/rnes_kort/Rnb----9721.pdf |
I tested your files: final original = PdfDocumentParser(
await File('Rnb-----9730.pdf').readAsBytes());
final tools = PdfTools(
compress: false,
verbose: true,
);
tools.addPages(original);
for (final o in tools.xref.objects) {
final p = o.params;
if (p is PdfDictStream) {
if (p.values['/Subtype'] == PdfName('/Image') &&
p.values['/Filter'] == PdfName('/DCTDecode')) {
print(p.values);
File('image_${o.objser}.jpg').writeAsBytesSync(p.decode().data);
print('Saved image_${o.objser}.jpg');
}
}
}
final result = tools.save();
final file = File('template.pdf');
await file.writeAsBytes(result); The DCTDecode filter represents an embedded Jpeg image. This particular image is 10012x7136 pixels, but the file seems corrupted. the iOS/MacOS jpeg decoder can't read it. Some software can open it, but shows an image of 10012x65280 pixels. If you can find a library on iOS that can read this jpeg data, it should be possible to rewrite the PDF with some correct data. |
Chrome / Safari can't display the attached image, but Firefox can. |
There are some PDF files that cannot be rendered at all on iOS but can be rendered on Android. I want to know if pdf_crypto can load these particular PDF files. I think it's a compression-related issue. If I read the pdf file with ghostscript and write it back, it successfully renders.
If pdf_crypto can read these PDF files, my client would like to purchase the licence. But first we need to know if it works. I can privately share some of these PDFs and you can confirm that it works. How should we proceed?
The text was updated successfully, but these errors were encountered: