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

Issues printing form fields

Explorer ,
Nov 21, 2022 Nov 21, 2022

I created an Action that uses javascript to add fields in specific locations and fill them with a value.  Essentially, the filename at the top left, the word PUBLIC in the top centre and the page # at the top right.

I then run the action on multiple PDF's.  This works perfectly fine and "stamps" the documents as intended.

 

The issue comes when I try to print.  If I send multiple documents to print, I noticed that the filename field at the top left doesn't change when it starts printing the next document.  For example, first print job prints document 000001.pdf and moves to next document 000002.pdf but the when you look at the printout for 000002.pdf, the field with the name shows 000001 at the top left.

 

The other scenario is I tried to print one pdf that had hundreds of pages but since it's the same PDF the field name should always be the same.  However, when you look at the printed pages, the field name changes.

 

I was wondering why this is happening because it's causing issues for us when reviewing as the "stamped" field name is different from the actual document name.  I was thinking I could flatten the document but that would delete all the comments/annotations in the document which are required.

 

Can anyone shed some light on why printing these documents is changing the field values during print jobs?

var re = /.*\/|\.pdf$/ig; 
var FileNM = this.path.replace(re,""); 
var Path = this.path; 
 
for (var p = 0; p < this.numPages; p++) { 
	var aRect = this.getPageBox("Crop",p); 
	var TotWidth = aRect[2] - aRect[0] 
	var TotHeight = aRect[1]
	var fd = this.addField("xftPage1"+p+1, "text", p, [10,TotHeight+14,90,TotHeight-30]);
		fd.value =  FileNM; 
		fd.textSize=12; fd.readonly = true; 
		fd.alignment="left";
		fd.textFont = font.HelvB;
		fd.textColor = color.black;
	var fd = this.addField("xftPage3"+p+1, "text", p, [(TotWidth/2)-60,TotHeight+14,(TotWidth/2)+60,TotHeight-30]);
	fd.value = "PUBLIC"; 
		fd.textSize=12; fd.readonly = true; 
		fd.alignment="center";
		fd.textFont = font.HelvB;
		fd.textColor = color.black;
	var fd = this.addField("xftPage2"+p+1, "text", p, [TotWidth-10,TotHeight+14,TotWidth-90,TotHeight-30]);
		fd.value =  "Page " + String(p+1); 
		fd.textSize=12; fd.readonly = true; 
		fd.alignment="right";
		fd.textFont = font.HelvB;
		fd.textColor = color.black;
}
TOPICS
General troubleshooting , JavaScript , Print and prepress
2.6K
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 21, 2022 Nov 21, 2022

Did you rename the file after creating the fields? Because they won't update automatically if you do that.

In order for that to happen you would need to embed a script into the file to update them whenever the file is opened (or saved).

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
Explorer ,
Nov 21, 2022 Nov 21, 2022

I believe at some point the files get renamed (they add Tab Numbers to the front).  We don't want the fields to update.  They should stay as is.  We're just not sure why it's changing during print jobs.  I know the print room queues up several PDF's at a time for print.  Would that be an issue when it completes one job and moves to the next and somehow retains the field values from the previous file?

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 21, 2022 Nov 21, 2022

No, that should not be happening.

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
Explorer ,
Nov 21, 2022 Nov 21, 2022

Is there anything wrong with the javascript code I used?  Perhaps it's not creating a proper field or something?

 

 

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 21, 2022 Nov 21, 2022

The issues I see with it are:

- It's not a good idea to reuse the same variable name ("fd") for all the fields, but it should still work.

- In the field names you should place the page number in brackets, like this:

"xftPage1"+(p+1)

If you don't it will be treated as a string, and the first one would be (for example):

"xftPage101"

- I would make the field with the file name longer, and set the font size to Auto, or it might cut off a part of the file name and you'll end up with incorrect results.

- If you want to make sure the fields are printed properly flatten the file at the end of the process.

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
Explorer ,
Nov 21, 2022 Nov 21, 2022

I was thinking of flattening the file but I'm worried about the comments being deleted after the flatten.  Is there anyway to flatten just the fields and retain comments?

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

It's tricky... What you can do is export the comments to an FDF file, delete them, then add the fields and flatten it, then import them back in.

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