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

Can I leave the filled text but remove the form fields automatically?

New Here ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

At work, we use a Microsoft Excel file that links to an Adobe file that is used to generate multiple tax forms at once. I did not make this file, but have been able to keep it running, which is no small feat. 

 

The way I understand it is: 

1. We enter information into Microsoft Excel. Two tabs of this file are set to pull this information and arrange it in a way that upon the push of a button, blank lines are deleted and each tab is saved as a comma delineated file. 

 

2. The macro then goes to find Adobe and Adobe runs javascript (I think?) that matches the comma delineated files to form names and fills the forms and saves in successive order (A1, A2, A3, etc.). Sometimes I have generated up to 64 forms this way. It's useful - a lot of the information is the same but a few lines on the tax form change with each form.

 

My issue: The forms that are saved still have the fields in them, meaning we cannot easily combine them into a PDF binder. They need to remain individual files (or maybe be a PDF portfolio, which is less ufesul than a binder to me). Is there script I can add that would LEAVE the text that was entered into the form, but make it just.... text, and not a fillable form field?  

 

Please go close to ELI5 if you can - I don't know javascript at ALL. I'm just the most techy one on the team.  I've anonymized file paths below but not changed anything else. 

 

 

// specify the filename of the data file
var fileName1 = "/Text_File_Path/Acq.txt";	// the tab delimited text file containing the data
var fileName2 = "/Text_File_Path/Rehab.txt";
var outputDir = "/Directory_In_Which_To_Save_PDFs_Path/";    // make sure this ends with a '/'

var err1 = 0;
var err2 = 0
var idx1 = 0;
var idx2 = 0;
while (err1 == 0) {
	err1 = this.importTextData(fileName1, idx1); // imports the next record
	if (err1 == -1)
		app.alert("Error: Cannot Open File");
	else if (err1 == -2)
		app.alert("Error: Cannot Load Data");
	// else if (err1 == -3)
		// We are not reporting this error because it does
		// indicate the end of our data table: We've exhausted
		// all rows in the data file and therefore are done with
		// processing the file. Time to exit this loop. 
		// app.alert("Error: Invalid Row");
	else if (err1 == 1)
		app.alert("Warning: User Cancelled File Select");
	else if (err1 == 2)
		app.alert("Warning: User Cancelled Row Select");
	else if (err1 == 3)
		app.alert("Warning: Missing Data");
	else if (err1 == 0) {
		this.saveAs(outputDir + this.getField("ProjectName").value + "_" + this.getField("AcqOrRehab").value + this.getField("BuildingNo").value + ".pdf"); // saves the file
		idx1++;
	}}


while (err2 == 0) {
	err2 = this.importTextData(fileName2, idx2); // imports the next record
	if (err2 == -1)
		app.alert("Error: Cannot Open File");
	else if (err2 == -2)
		app.alert("Error: Cannot Load Data");
	// else if (err2 == -3)
		// We are not reporting this error because it does
		// indicate the end of our data table: We've exhausted
		// all rows in the data file and therefore are done with
		// processing the file. Time to exit this loop. 
		// app.alert("Error: Invalid Row");
	else if (err2 == 1)
		app.alert("Warning: User Cancelled File Select");
	else if (err2 == 2)
		app.alert("Warning: User Cancelled Row Select");
	else if (err2 == 3)
		app.alert("Warning: Missing Data");
	else if (err2 == 0) {
		this.saveAs(outputDir + this.getField("ProjectName").value + "_" + this.getField("AcqOrRehab").value + this.getField("BuildingNo").value + ".pdf"); // saves the file
		idx2++;
	}}

 

 

 

TOPICS
How to , JavaScript , PDF forms

Views

198

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 ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

You can use:

this.flattenPages();

Votes

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 ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

Enter this.flattenPages(); just before this.saveAs....

Votes

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 ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

I'm not sure if I entered it wrong or if this isn't what I need. 

Normally it might give me, from one Excel file, say "A1, A2, A3, A4, A5, A6, R1, R2, R3, R4, R5, R6" so I end up with 12 PDF files. Each has appropriately pulled the data from the txt files, and I have only pushed the button in Excel once. So it pulls all the data for A1, saves the file, puls the data for A2, saves the file, etc. 

I tried entering the this.flattenPages(); in this way: 

else if (err1 == 2)
		app.alert("Warning: User Cancelled Row Select");
	else if (err1 == 3)
		app.alert("Warning: Missing Data");
	else if (err1 == 0) {
		this.flattenPages();
		this.saveAs(outputDir + this.getField("ProjectName").value + "_" + this.getField("AcqOrRehab").value + this.getField("BuildingNo").value + ".pdf"); // saves the file
		idx1++;
	}}

 

It only pulled the information for A1, and stopped with a flattened PDF for me. I think I need it to pull data, flatten, save flattened, then pull data for the next one, flatten, save, etc. 

 

Did I enter it wrong, explain it wrong, or some combination? 

Votes

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 ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

You can't do it like that, as flattening removes the fields from the flattened pages.

If you want to use the data in those fields you must save it into a variable (or variables) before flattening them.

Votes

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 ,
Sep 12, 2024 Sep 12, 2024

Copy link to clipboard

Copied

LATEST

It only save one because there will be an error after flattening as the fields no longer exist.  Instead of using this.flattenPages() in this script, you can create an Action to "Execute JavaScript" with that one line of code, this.flattenPages(); and run the Action on the entire folder once the files have been saved.  Another method is to leave the code in the script, but close the document after saving and reopen the original before importing the next row of data.  Where is the is script running from?

Votes

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