Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

about plugin SDK

Guest
Nov 02, 2016 Nov 02, 2016

I'm trying to develpe a plugin, to insert some annotations into the PDF file. But I don't know how use the function PDAnnotSetColor , please help to give me an detail example to change the color of annotation.

TOPICS
Acrobat SDK and JavaScript
803
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 02, 2016 Nov 02, 2016

Fill in the color space and color value of a PDColorRec. Pass the annoy and color. It must be an RGB color space. please let us know which parts of documentation or my explanation are unclear.

Translate
LEGEND ,
Nov 02, 2016 Nov 02, 2016

Fill in the color space and color value of a PDColorRec. Pass the annoy and color. It must be an RGB color space. please let us know which parts of documentation or my explanation are unclear.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 02, 2016 Nov 02, 2016

Dear Test Screen Name,

Sorry, I'm just a beginner of developer based on C++.  Please help to finallize the following code for me, I want to change the color of the annotation to red, how to do? Thanks.

  PDColorValue color;

  PDPage page = NULL;

  PDAnnot annot,textannot;

  char* ptr = "This is initial text";

  //Create an ASFixed object and define its borders

  ASFixedRect fr;

  fr.left = ASInt32ToFixed(36);

  fr.top = ASInt32ToFixed(792-36);

  fr.right = ASInt32ToFixed(136);

  fr.bottom = ASInt32ToFixed(792-136);

  //Create an ASPage object

  page = PDDocAcquirePage(myPDDoc, 0);

  //Create a PDAnnot object

  annot = PDPageCreateAnnot (page, ASAtomFromString("FreeText"),&fr);

  //Cast the PDAnnot object to a PDTextAnnot object

  textannot = CastToPDTextAnnot(annot);

  //Open the annotation, set the text, and add it to a page

  PDTextAnnotSetOpen (textannot, true);

  PDTextAnnotSetContents (textannot, ptr, strlen (ptr));

  PDPageAddAnnot(page,-2, textannot);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2016 Nov 02, 2016

Do not declare a PDColorValue, this is the name of the pointer. Instead, declare a value of type PDColorValueRec. And pass the ADDRESS of the value to PDAnnotSetColor. This method (XXX pointer and XXXRec actual structure) is very common.


Examine the documentation and/or header files to see the fields in a PDColorValueRec. It includes further structures which must also be filled in.

Further key information you need: (1) in PDF, there are 11 colour spaces such as (but not exactly) RGB, CMYK, Lab. For a colour to have meaning you need to give the space. (2) You may be used to colour value in the range 0 to 255, but that is NOT the rule for PDF. For RGB and most other colours they are floating point values (or equivalent ASFixed) in the range 0.0 to 1.0 (3) convert by dividing by 255.

Please have a go and show us your code, so that we can correct if necessary and help you to an understanding of the documentation. I will never write lines of code in reply to a question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 03, 2016 Nov 03, 2016

Thanks for your instruction, please see following code which pass the compiling, but the color of the annotation still not change.

AVDoc avDoc = AVAppGetActiveDoc();
PDDoc myPDDoc = AVDocGetPDDoc(avDoc);
//Create an ASPage object
PDPage page = NULL;
page = PDDocAcquirePage(myPDDoc, 0);
PDColorValueRec colorRec;
colorRec.space=PDDeviceRGB;
//memset(&colorRec, 0x00, sizeof(colorRec));
colorRec.value[0]=200;
colorRec.value[1]=0;
colorRec.value[2]=0;
colorRec.value[3]=1;
PDAnnot annot;
char* ptr = "Hello";
//Create an ASFixed object and define its borders
ASFixedRect fr;
fr.left = ASInt32ToFixed(36);
fr.top = ASInt32ToFixed(792-36);
fr.right = ASInt32ToFixed(136);
fr.bottom = ASInt32ToFixed(792-136);
annot = PDPageGetAnnot(page,0);
//Create a PDAnnot object
annot = PDPageCreateAnnot (page, ASAtomFromString("FreeText"),&fr);
//Cast the PDAnnot object to a PDTextAnnot object
//textannot = CastToPDTextAnnot(annot);
//Open the annotation, set the text, and add it to a page
PDTextAnnotSetOpen (annot, true);
PDAnnotSetColor(annot,&colorRec);
//PDAnnotSetColor(textannot,&colorRec);
PDTextAnnotSetContents (annot, ptr, strlen (ptr));
PDPageAddAnnot(page,-2, annot);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 04, 2016 Nov 04, 2016

you have set the color value to 200.  As I noted the range is 0.0-1.0

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 04, 2016 Nov 04, 2016

Thanks. Actually, I have tested with value of 0.5 at the beginning, but no effect, so I change back 200. After your instruction, I set to 0.5 again, but still no use. Could you please spend a little time to look into my rest code and find the solution for me? And I want to add red annotation without the border, is this a correct method to create a real Free text annotation? If I defined the &fr, and there must be a border. Sorry, since the API developer examples are too few, I can not find many useful resource.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 04, 2016 Nov 04, 2016

What do you mean by “red annotation”? Text is red? Border is red? Background is red?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2016 Nov 06, 2016

Only text and border are red,  background is transparent. Do you have any good idea?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 04, 2016 Nov 04, 2016

Color Values are ASFixed, I believe. Please check. If they are, you must convert the value to ASFixed from the floating point constant.

You typically need knowledge of the PDF spec to go beyond the basics in the API. This is part of the SDK, though its 1000 pages can be daunting.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 07, 2016 Nov 07, 2016
LATEST

I suggest you correct the colour values as I suggested.

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