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

Add Circle and Page Numbers

New Here ,
Nov 09, 2022 Nov 09, 2022

I've draw a circle and a text '1' on a page and tried to duplcate the circle to the remaining pages with incrementing numbers to the following pages. 

 

Anyone know how to do this with JavaScript?

 

Thanks,

TOPICS
Edit and convert PDFs , How to , JavaScript
1.7K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 09, 2022 Nov 09, 2022

The best way to do this is to create a custom dynamic stamp. Which you can read about here:

https://www.pdfscripting.com/public/All_About_PDF_Stamps.cfm

 

It could also be done by using a combination of a circle annotation and a textbox annotation. 

 

Either way you'll need to understand PDF page coordinates to create a script for automating the placement of these annotations.

Which you can read about here:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm

 

Automating this process is not a particularly difficult task, but it does require some advanced skills. 

 

 

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

View solution in original post

Translate
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 ,
Nov 09, 2022 Nov 09, 2022

The circle can be created using a "Circle"-type comment, which can be added using the addAnnot method.

The text can also be a comment, or a text field, which can be added using the addField method.

Translate
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 ,
Nov 09, 2022 Nov 09, 2022

The best way to do this is to create a custom dynamic stamp. Which you can read about here:

https://www.pdfscripting.com/public/All_About_PDF_Stamps.cfm

 

It could also be done by using a combination of a circle annotation and a textbox annotation. 

 

Either way you'll need to understand PDF page coordinates to create a script for automating the placement of these annotations.

Which you can read about here:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm

 

Automating this process is not a particularly difficult task, but it does require some advanced skills. 

 

 

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

Translate
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 ,
Nov 09, 2022 Nov 09, 2022

The circle and number will be placed on the same location of each page. Would it make the Scipt a bit eaiser?

Translate
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 ,
Nov 09, 2022 Nov 09, 2022
LATEST

Yes, for example one technique would be to place the first annotation manually, then use the code you've already seen to copy the annot by copying the annot props and changing the page number. 

But the circle with number presents a challenge, since you'll need to create two annotations. I'd suggest this.  Manaully place a circle on first page. Select it, then run this script in the console window. Or make it a folder level function.

 

 

// Place number in circle
props.type = "FreeText";
props.contents = inc.toString();
inc++;
this.addAnnot(props);
// Add circle number combo to all pages
for(var i=1;i<this.numPages;i++){
   props.page = i;
   props.type = "Circle";
   this.addAnnot(props);
   props.type = "FreeText";
   props.contents = inc.toString();
   this.addAnnot(props);
   inc++
}

 

This method is a bit crude and adhoc.  You'll notice that the number is not centered.  One fix would be to add the text annot up front and select both the initial circle and number, then use separate props objects for each. There are lots of other ways this could be done.  But I have to go back to my original comment. A custom dynamic stamp is the best solution. 

 

 

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

Translate
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 ,
Nov 09, 2022 Nov 09, 2022

I assume you don't have the original file that created the pdf, where you could add the page numbers.

Are you comfortable with InDesign? If so here is another work-around;

Create a new InDesign file at the desired page size and place a round text box on the parent page (AKA master page) filled with an auto page number (Type> Insert Special Character> Markers> Current Page Number). Set the text alignment to center and the text frame option- vertical justification- align to center. Now place your existing pdf into all pages using the included script "Place multipage pdf", this will create a multipage InDesign file with correct page numbers, export to a new pdf. I can provide better step by step instructions, if you are interested.

parent page.png

Translate
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