How i to use PDDocCreatePDCollection function in sdk >9.0

New Here ,
Sep 19, 2017

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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).

TOPICS
Acrobat SDK and JavaScript

Views

572

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How i to use PDDocCreatePDCollection function in sdk >9.0

New Here ,
Sep 19, 2017

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Test Screen Name | Most Valuable Participant

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).

TOPICS
Acrobat SDK and JavaScript

Views

573

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 19, 2017 0
Adobe Employee ,
Sep 19, 2017

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 19, 2017 0
New Here ,
Sep 19, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 19, 2017 0
Explorer ,
Sep 20, 2017

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2017 0
New Here ,
Sep 20, 2017

Copy link to clipboard

Copied

yeah, thanks

i use the same version Acrobat to match the SDK  will be ok.

but how to compile one plus-ins for all version Acrobats

or i need to make plus-ins for one by one?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2017 0
New Here ,
Sep 20, 2017

Copy link to clipboard

Copied

i check it again.

the plus-ins compile it with sdk >9.0 ,the PDDocCreatePDCollection will be work ok in version >9.0 Acrobat

so it's obvious sdk 9.0 & >9.0 has some difference .

thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2017 0
Most Valuable Participant ,
Sep 20, 2017

Copy link to clipboard

Copied

Please give more details of exact versions. Which version of Acrobat and which version of the SDK together fail? Which ones work? It's not enough to talk only of SDK version.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2017 0
New Here ,
Sep 20, 2017

Copy link to clipboard

Copied

if i compile puls-ins with sdk XI,it  works ok on Acrobat version>9.0 all.

but it will be failed in 9.0.

if i comlile it with sdk 9.0,it works failed on version >9.0. it will be only support  Acrobat 9.0

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 20, 2017 0
Explorer ,
Sep 21, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2017 0
Most Valuable Participant ,
Sep 21, 2017

Copy link to clipboard

Copied

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).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2017 0
New Here ,
Sep 21, 2017

Copy link to clipboard

Copied

No,I'm replace the all sdk file .

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2017 0
New Here ,
Sep 22, 2017

Copy link to clipboard

Copied

Thanks,You mean if we call a proc ,the Arcobat just call it as Index not by name.

So we if call PDDocCreatePDCollection with different sdk in same Acrobat it will don't have same result?

I 'm  building two plug-ins...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 0
Most Valuable Participant ,
Sep 21, 2017

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2017 0
Most Valuable Participant ,
Sep 22, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 0
New Here ,
Sep 22, 2017

Copy link to clipboard

Copied

Thank you so much.

I have learn more from this

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 0
Explorer ,
Sep 22, 2017

Copy link to clipboard

Copied

So is there someone who can now record this as a bug at Adobe and get this fixed. Leonard - are you onto this one?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 0
Adobe Community Professional ,
Sep 22, 2017

Copy link to clipboard

Copied

Michael, to make sure that Leonard sees this, you need to make a formal "mention" (start with the @ character and then start to type a forum user name, and then pick from the list. Sometimes you have to type the full name): lrosenth​ - this way he will get a notification.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 1
Explorer ,
Sep 22, 2017

Copy link to clipboard

Copied

Karl Karl Heinz Kremer​, thanks for the heads up.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2017 0
lrosenth LATEST
Adobe Employee ,
Sep 23, 2017

Copy link to clipboard

Copied

There was one bad version which has the problem you describe – but AFAIK, if you use the last dot releases of each version 9.x, 10.x, along with the correct SDK, everything is fine.

However, as noted earlier in the thread – SDKs are only forward compatible not backwards.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2017 1