I'm trying to place a FreeText annotation on a number of drawings using javascript. I can control almost all of the properties of the annotation, except textSize and alignment.
Here's a simple sample program that doesn't work, copied straight from the Acrobat JavaScript Scripting Reference, with the exception of the contents field, which I added:
// Create FreeText annotation with Helvetica
var annot = this.addAnnot({
page: 0,
type: "FreeText",
textFont: font.Helv, // or, textFont: "Viva-Regular",
textSize: 10,
rect: [200, 300, 200+150, 300+3*12], // height for three lines
width: 1,
alignment: 1,
contents: "Test Text." });
What I get is an otherwise expected textbox with 9 point type, left justified. My reading of the Scripting Reference tells me that I should get 10 point type, centered. If I change the textSize or alignment parameters, I still get 9 point type, left-justified. These results are consistent with my other attempts to control font size and alignment.
I suspect that I'm either missing something, or that these parameters aren't actually supported, or that the documentation isn't correct.
Thanks for any help.
annot = addAnnot(...);
annot.textSize = 10;
annot.textFont = ...;
annot.contents = "...";
I'm using Acrobat 8 Pro. Unfortunately, the alignment parameter does not seem to work at all when set from JavaScript. This is definately a bug. I haven't tried it in Acrobat 9 to see if it's been fixed, but this is exactly the kind of thing that slips by from version to version.
Have you tried using the "richContents" property instead of setting the annot level properties? You might have better luck with it
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script