View Single Post
Old March 15th, 2019, 01:35 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
Join Date: Feb 2011
Posts: 213
Default Re: Original Input File Name Path

The job is a regular template in acrobat that is then sent to the API server for composition.

What happens is data files are placed on a file server in a folder that is the job number. The input file itself is named in a predictable way but does not contain the job number, only the folder it's in has it.

The workflow is that the template is opened and the input file assigned, then it's sent to a producer server for composition. What I am attempting to do is read the folder name, ie the job number, and then rename the output file prefixed with the job number.

I did end up writing a function that reads in the def file to grab the job number. It works fine for this job but it seems like there should be an easier way to do it. The frustrating thing about this function is I have to hardcode in the template name and hope no one changes it or the def file wont read.

It would be really nice if there was a way to read the original input file path, which is already preserved in the def file. It would also be nice if the PDF template name was also preserved somewhere. I know I could have used that a few times on other projects.

If you have any other ideas on how to achieve this, I'd love to hear them. Here is the function I currently have working to get the number from the def file.

function get_job_no(template_name)
	var iname = FusionPro.inputFileName;
	var job_no = iname; //get number from iname in case job is composed locally
	if (FusionPro.Composition.isBatch)
		var iname_path = iname.replace(/[^\\]*$/, ""); //gets path without file name
		var def_name = template_name.replace(/.pdf/i, "") + ".def";
		var XDF = new ExternalDataFileEx(iname_path + "\\" + def_name, "\t");
		job_no = XDF.GetFieldValue(8, 0);
	return job_no.replace(/.+\\(.+)\\[^\\]+$/, '$1'); //gets last folder name from iname or XDF
Reply With Quote