programmatically add text on document

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

defcon8808
User
Posts: 64
Joined: Sat Dec 13, 2014 6:59 am

programmatically add text on document

Post by defcon8808 »

Hello. I'm VB .Net Programmer.

I finding to method programmatically add text on document. Then I get/set coordinate of add text.

I try this javascript code. By Adobe "js_api_reference.pdf"

Code: Select all

AxCoPDFXCview1.RunJavaScript(var text = this.addWatermarkFromText(" & Chr(34) & "Confidential" & Chr(34) & ", 0, font.Helv, 24, color.red);")
Result Error : "Unknown error: 0x80131604"

Code: Select all

AxCoPDFXCview1.RunJavaScript(var text = this.addWatermarkFromText(" & Chr(34) & "Confidential" & Chr(34) & ", 0, font.Helv, 24, color.red);", "", 0, 0)
Result Error : "An error occured in java script"
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: programmatically add text on document

Post by Stefan - PDF-XChange »

Hello defcon8808,

Trying to use this in the end user Viewer:

Code: Select all

this.addWatermarkFromText("Confidential", 0, font.Helv, 24, color.red);
results in this error:
this.addWatermarkFromText is not a function. So it seems like this method is not supported.

It works correctly in the Editor, though the SDK for it is still some time away.

Regards,
Stefan
defcon8808
User
Posts: 64
Joined: Sat Dec 13, 2014 6:59 am

Re: programmatically add text on document

Post by defcon8808 »

Thanks...
Is impossible programmtically add text on document??
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: programmatically add text on document

Post by Stefan - PDF-XChange »

Hi defcon8808,

Adding base content is possible using the PDF Tools SDK and the Watermakr feature there, but not the Viewer SDK I am afraid.
You can add annotations and then lock/flatten them though with the Viewer SDK as well.

Regards,
Stefan
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: programmatically add text on document

Post by Vasyl - PDF-XChange »

Hi, defcon8808.

I can suggest one method to add text on the page:

// add new text annotation on first page:

Code: Select all

var annot = this.addAnnot
({
page: 0,
type: "FreeText",
rect: [200,400,500,380],
width: 0,
strokeColor: color.black,
contents: "I need a little help with that.",
});
// flatten first page (all annotations(interactive drawings, texts) appearances will be added into page's content and all annotation-objects(excepting links) will be removed from page):

Code: Select all

this.flattenPages(0, 0, 1);
HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.