Copy link to clipboard
Copied
You can find attachments using PDDocGetNameTree in Acrobat SDK.
However, I want to find the number of MAX pages and the named destination of the attached file.
Copy link to clipboard
Copied
Do you mean you want to find the number of pages of each attached file (Do you can get the maximum)?
I don’t understand the second requirement, sorry.
Copy link to clipboard
Copied
1. Number of pages of the attached file.
2. The destination of the attached file.
I want to ask 1,2.
Copy link to clipboard
Copied
Ok, you will need to open the file on a PDDoc object. I have never done this, but I feel that the methods PDFileAttachmentFromCosObj and PDFileAttachmentOpenStream would be at the heart of any solution.
You could also process the name tree entries as Cos objects, get an ASStm and open it.
Copy link to clipboard
Copied
I tried it in the following way, but I am just reading the attached file.
// Procedure called by PDNameTreeEnum
ACCB1 ASBool ACCB2 extractor(CosObj obj, CosObj value, void *clientData)
{
char theBufferPtr[1024];
PDFileAttachment fileAttachment = PDFileAttachmentFromCosObj(value);
ASStm asStm = PDFileAttachmentOpenStream( fileAttachment);
ASInt32 theItemsRead = ASStmRead( theBufferPtr, sizeof( char ), 1024, asStm );
AVAlertNote ( theBufferPtr);
if (asStm){
ASStmClose(asStm);
}
}
From now on how can you be asked as follows?
ASInt32 lastPage = PDDocGetNumPages (pddoc);
PDNameTree pdNT = PDDocGetNameTree (pddoc, ASAtomFromString ("Dests"));
Copy link to clipboard
Copied
You have to open a PDDoc on the ASStm object. I don’t know exactly which APIs you will use but that must be part of your solution.
Possibilities include writing a temporary file and opening it, or creating a custom ASFileSys.
If the container PDF is a portfolio the ASFileAttachment APIs are helpful.