I am looking for a JavaScript API that can draw a line in PDF

Community Beginner ,
Jun 14, 2018

Copy link to clipboard

Copied

I am looking to create a new PDF with lines drawn on it.

I was wondering if there was a way to draw lines/shapes on PDF using JavaScript. ( I know that this can be achieved by C++ coding or the comment mode function in PDF)

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

An even easier solution is to use the line markup annotation.

this.addAnnot({type:"Line", page:0, points:[....]});

 

There are all kinds of graphical annotations. Keep in mind these are not part of the PDF page content.

Read this:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm?sd=40

 

If this will be performed from a privileged script, then there are more possibilities for new document create with JavaScript. For example flattening will push anntation and field appearances into the PDF content. And there is the Report Object, which has the ability to create horizontal lines. 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

886

Likes

Translate

Translate

Report

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

I am looking for a JavaScript API that can draw a line in PDF

Community Beginner ,
Jun 14, 2018

Copy link to clipboard

Copied

I am looking to create a new PDF with lines drawn on it.

I was wondering if there was a way to draw lines/shapes on PDF using JavaScript. ( I know that this can be achieved by C++ coding or the comment mode function in PDF)

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

An even easier solution is to use the line markup annotation.

this.addAnnot({type:"Line", page:0, points:[....]});

 

There are all kinds of graphical annotations. Keep in mind these are not part of the PDF page content.

Read this:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm?sd=40

 

If this will be performed from a privileged script, then there are more possibilities for new document create with JavaScript. For example flattening will push anntation and field appearances into the PDF content. And there is the Report Object, which has the ability to create horizontal lines. 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

887

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 14, 2018 0
Adobe Employee ,
Jun 14, 2018

Copy link to clipboard

Copied

No, there is not a way to do that with JavaScript in PDF.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 14, 2018 1
New Here ,
Feb 04, 2020

Copy link to clipboard

Copied

Actually there is a way.  Just have to be a little creative.

var SV1=this.getField("line1");SV1.rect = [45,517.5,409.5,516.8];
var SV2=this.getField("line2");SV2.rect = [45,504.648,409.5,503.948];
var SV3=this.getField("line3");SV3.rect = [45,491.976,409.5,491.276];
var SV4=this.getField("line4");SV4.rect = [45,479.304,409.5,478.604];
var SV5=this.getField("line5");SV5.rect = [45,466.632,409.5,465.932];

 

and then just make sure each of those field box has a border outline

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 04, 2020 0
Adobe Community Professional ,
Feb 05, 2020

Copy link to clipboard

Copied

An even easier solution is to use the line markup annotation.

this.addAnnot({type:"Line", page:0, points:[....]});

 

There are all kinds of graphical annotations. Keep in mind these are not part of the PDF page content.

Read this:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm?sd=40

 

If this will be performed from a privileged script, then there are more possibilities for new document create with JavaScript. For example flattening will push anntation and field appearances into the PDF content. And there is the Report Object, which has the ability to create horizontal lines. 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 05, 2020 0