Open rmhrisk opened 7 years ago
I have the interest, and I could do it if I find a way to extract the xml :)
My hope is that when @YuryStrozhevsky creates his SDK we get something similar to:
Map<String, byte[]> files = new HashMap<String,byte[]>();
PdfReader reader = new PdfReader(pdfPath);
PdfDictionary root = reader.getCatalog();
PdfDictionary names = root.getAsDict(PdfName.NAMES); // may be null
PdfArray embeddedFiles = names.getAsArray(PdfName.EMBEDDEDFILES); //may be null
int len = embeddedFiles.size();
for (int i = 0; i < len; i += 2) {
PdfName name = embeddedFiles.getAsName(i); // should always be present
PdfDictionary fileSpec = embeddedFiles.getAsDict(i+1); // ditto
PRStream stream = (PRStream)fileSpec.getAsStream(PdfName.EF);
if (stream != null) {
files.put( PdfName.decodeName(name.toString()), stream.getBytes() );
}
}
In theory, we can progress with a static file and add extracting real time later, not saying we need to, just saying possible.
I will create a parser for the static file, and as soon as the SDK is ready I will incorporate everything to tl-create.
@fotisl in the absence @YuryStrozhevsky forthcoming SDK if your interested in looking there is a python tool called pdftk that can unpack PDFs:
pdftk mydoc.pdf unpack_files
@fotisl looks like we can do with PDFjs also - https://github.com/mozilla/pdf.js/blob/de7002dc6c7a6fc3d3ee1107a8480953b60b9555/src/core/annotation.js#L1053
If you wanted to do it this way I think @apilguk could help with the PDFjs call.
I am reopening this to track the further enhancements:
The adobe AATL list is downloadable here: http://trustlist.adobe.com/tl12.acrobatsecuritysettings
This is a PDF that contains an XML file that looks like this: SecuritySettings.xml.zip
We need to support:
We have what we need for #1 and #3, @YuryStrozhevsky will give us an SDK that lets us attach and embed attachments in the next month or so.
We could hard code the example securitysettings.xml file and make the rest work and add that in later.
'CCing @fotisl incase he has time and interest :)