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

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

Community Beginner ,
Jun 14, 2018 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)

TOPICS
Acrobat SDK and JavaScript

Views

2.3K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 05, 2020 Feb 05, 2020

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

...

Likes

Translate

Translate
Adobe Employee ,
Jun 14, 2018 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
community guidelines
New Here ,
Feb 04, 2020 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
community guidelines
Community Expert ,
Feb 05, 2020 Feb 05, 2020

Copy link to clipboard

Copied

LATEST

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. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines