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

AFLayoutText causes failure in creating appearance

Explorer ,
Sep 28, 2016 Sep 28, 2016

In Acrobat 11 I'm using AFLayout object to create annotation appearance. I want it to have background and some text on it. Everything seems to run fine but, when I  use also method AFLayoutText as in the sample below it creates null CosObj. Without the text method works fine and the appearance is created correctly. Am I missing something?

Thanks

       

    ASFixedRect rect;

    PDAnnotGetRect(annot, &rect);

    AFLayout layout = AFLayoutNew(&rect, pdRotate0, cosDoc);

    // border and background

    AFPDWidgetBorderRec border;

    border.nStyle = AFPDWBSolid;

    border.nWidth = 0;

    PDColorValueRec brdrColor = { PDDeviceRGB, { fixedOne, fixedZero, fixedZero, fixedZero } };

    PDColorValueRec bkndColor = { PDDeviceRGB, { fixedOne, fixedZero, fixedZero, fixedZero } };

    AFLayoutBorder(layout, &border, &brdrColor, &bkndColor, false);

    // text

    TextAppearance_t ta;

    SetDefault_TextAppearanceP(&ta);

    AFLayoutText(layout, false, false, &border, &ta, "OK");

    // create stream cosObj

    CosObj cosN = AFLayoutCreateStream(layout);

     AFLayoutDelete(layout);

TOPICS
Acrobat SDK and JavaScript
693
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

Explorer , Oct 04, 2016 Oct 04, 2016

AFDrawText solved my problem

Translate
Adobe Employee ,
Sep 28, 2016 Sep 28, 2016

I don’t see the call to AFLayoutCreateStream

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
Explorer ,
Sep 28, 2016 Sep 28, 2016

Let me post the code again. AFLayoutCreateStream is at the bottom.

Screenshot 2016-09-28 16.26.21.png

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 ,
Sep 28, 2016 Sep 28, 2016

You have to create the stream BEFORE you call LayoutNew()

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
Explorer ,
Sep 28, 2016 Sep 28, 2016

Before? Are you sure?

Acrobat_Forms_Layer.AcroForm (Acrobat)  says:

Syntax

CosObj AFLayoutCreateStream(void* vlayout)

Creates a layout stream that can be used as an annotation appearance.

Parameters

vlayout —

The layout of the annotation. Use AFLayoutNew() to create a new layout before calling this method.

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 ,
Sep 28, 2016 Sep 28, 2016

Sorry – wrong method. Order is:

AFLayoutNew()

AFLayoutCreateStream()

AFLayoutBorder()

AFLayoutText()

AFLayoutDelete()

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
Explorer ,
Sep 28, 2016 Sep 28, 2016

That does not work and also does not make sense.

AFLayoutNew then AFLayoutCreateStream return CosNull - which is obvious because no border/background was set. Even if it would be CosStream calling AFLayoutBorder and/or AFLayoutText does not affect already created CosObj.

I thought AFLayout works like this:

1. create with AFLayoutNew

2. set properties using AFLayoutBorder, AFLayoutText

3. create stream AFLayoutCreateStream

Other options I tried:

AFLayoutNew, AFLayoutBorder then AFLayoutCreateStream return CosStream - all ok in this case, appearance created.

AFLayoutNew, AFLayoutBorder, AFLayoutText then AFLayoutCreateStream returns CosNull unless text is an empty string.

My observation is that AFLayoutText with provided TextAppearance somehow causes AFLayout to fail when creating stream. Passing an empty string makes it work, so it points to some issue with processing text inside of the AFLayout. After calling AFLayoutCreateStream Acrobat fills in AcroForm object in document root with Fields and DR key which includes Encoding (PDFDocEncoding) and Font dictionary with Helv font entry (I tested also Arial as a font name with same result).

Any other ideas?

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 ,
Sep 29, 2016 Sep 29, 2016

I’ve looked over some sample code and that is what it does…Sorry, I’ve never used those APIs myself.

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
Explorer ,
Sep 29, 2016 Sep 29, 2016

Ok got it. Then I gave to create appearance manually...

Thanks

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
Explorer ,
Oct 04, 2016 Oct 04, 2016
LATEST

AFDrawText solved my problem

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