Skip to main content
Participating Frequently
September 19, 2017
Answered

How i to use PDDocCreatePDCollection function in sdk >9.0

  • September 19, 2017
  • 3 replies
  • 2534 views

I want to create a PDCollection.

In sdk 9.0 i use as fallow

PDDoc newDoc = PDDocCreate();

PDCollection pdCollect = PDDocCreatePDCollection(newDoc);

...

it's ok

but when i use sdk > 9.0

PDDocCreatePDCollection will return error.

it's come an error : error Parameters

This topic has been closed for replies.
Correct answer Test Screen Name

When you move between SDKs are you also replacing PIMain.c in your code to match each SDK?


Hmm. It's hard to believe, but Adobe seem to have messed this up.

In the Acrobat 9 SDK we find in PDProcs.h a selection of routine definitions

NPROC(void, PDFileAttachmentSetFieldText, (PDFileAttachment attachment, ASAtom fieldID, ASText text))

NPROC(ASBool, PDFileAttachmentGetFieldText, (PDFileAttachment attachment, ASAtom fieldID, ASText text))

NPROC(void, PDFileAttachmentSetFieldNumber, (PDFileAttachment attachment, ASAtom fieldID, float number))

NPROC(ASBool, PDFileAttachmentGetFieldNumber, (PDFileAttachment attachment, ASAtom fieldID, float *number))

In a later SDK we find

NPROC(void, PDFileAttachmentSetFieldText, (PDFileAttachment attachment, ASAtom fieldID, ASText text))

NPROC(void, PDFileAttachmentSetFieldStyledText, (PDFileAttachment attachment, ASAtom fieldID, ASConstText text))

NPROC(ASBool, PDFileAttachmentGetFieldText, (PDFileAttachment attachment, ASAtom fieldID, ASText text))

NPROC(ASBool, PDFileAttachmentGetFieldStyledText, (PDFileAttachment attachment, ASAtom fieldID, ASText text))

NPROC(void, PDFileAttachmentSetFieldStyle, (PDFileAttachment attachment, ASAtom fieldID, ASConstCab styles))

NPROC(ASBool, PDFileAttachmentGetFieldStyle, (PDFileAttachment attachment, ASAtom fieldID, ASCab styles))

NPROC(void, PDFileAttachmentSetFieldNumber, (PDFileAttachment attachment, ASAtom fieldID, float number))

NPROC(ASBool, PDFileAttachmentGetFieldNumber, (PDFileAttachment attachment, ASAtom fieldID, float *number))

This is absolutely against how the header files must be maintained. Because later in the same header file we find the definition of PDDocCreatePDCollection. Why does it matter? Because each NPROC adds 1 to the current HFT entry. This means that if we use any routine after this point in PDProcs we will be calling the wrong code, with all sorts of bad consequences.

The easy way to resolve this is to build two plug-ins. Building one plug-in is not actually impossible, but is going to need very low level and detailed understanding of how HFTs work. I wouldn't like to do it (though I would if I had to).

3 replies

Brainiac
September 22, 2017

Acrobat calls all plugin methods by a number, that is correct. (details: study "HFT"). The number comes from the header files and has to match the number used inside that version of Acrobat.

Adobe have been very, very careful to make sure the numbers never change. This is quite simple: new methods are always added to the end of the list. Unfortunately, it seems someone at Adobe was working in the header files and didn't know the rules. It affects all the methods in PDProcs.h which appear in the SDK 9 starting with PDFileAttachmentGetFieldText. This is not many methods and you may be the first to discover it. There is nothing that can be done to fix the mistake.

Participating Frequently
September 22, 2017

Thank you so much.

I have learn more from this

Brainiac
September 21, 2017

SDKs are not backwards compatible. Something compiled with SDK 11 should not even load in Acrobat 10 or 9. But they should be forwards compatible except across architecture changes. (Such as Acrobat DC on Mac which needs the DC headers).

So, something compiled with SDK 9 should work in Acrobat 10,11, and on Windows DC. It doesn't?

lrosenth
Adobe Employee
Adobe Employee
September 19, 2017

Should work exactly the same way.

Are you using DURING/HANDLER blocks to check for errors? Did you do a PDCollectionIsValid() to check the result?

Participating Frequently
September 20, 2017

PDCollectionIsValid checks if a PDCollection is valid. but i call PDDocCreatePDCollection has failed

my code is like this.

when i compile with sdk 9.0 it's work ok. but if use sdk x or >x it's will come this error

PDDoc newDoc = PDDocCreate();
DURING
PDCollection pdCollect = PDDocCreatePDCollection(newDoc);
HANDLER

  // exception handling
  char errorMsg[256];
ASGetErrorString (ASGetExceptionErrorCode(), errorMsg, 256);
// if(aspItem!=NULL) ASFileSysReleasePath(fileSys, aspItem);
// if(theFolder!=NULL) ASFileSysReleasePath(fileSys, theFolder);

// display an error message.
if(ASBoolToBool(bEcho)==true) {//
  AVAlertNote (errorMsg);
}
END_HANDLER

....

other code..

errorMsg just display Parameters is error

Inspiring
September 20, 2017

Are you using the same version of Acrobat to match the SDK when you move to a higher version of the SDK? Otherwise which version of Acrobat are you using? Is this Mac or PC?