Copy link to clipboard
Copied
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);
AFDrawText solved my problem
Copy link to clipboard
Copied
I don’t see the call to AFLayoutCreateStream
Copy link to clipboard
Copied
Let me post the code again. AFLayoutCreateStream is at the bottom.
Copy link to clipboard
Copied
You have to create the stream BEFORE you call LayoutNew()
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Sorry – wrong method. Order is:
AFLayoutNew()
AFLayoutCreateStream()
AFLayoutBorder()
AFLayoutText()
…
AFLayoutDelete()
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I’ve looked over some sample code and that is what it does…Sorry, I’ve never used those APIs myself.
Copy link to clipboard
Copied
Ok got it. Then I gave to create appearance manually...
Thanks
Copy link to clipboard
Copied
AFDrawText solved my problem
Find more inspiration, events, and resources on the new Adobe Community
Explore Now