Jump to content

How do I get the input PDF filename?


Recommended Posts

Is there a way to get the input file name (e.g. input.pdf instead of the csv) via the JavaScript?

 

or

 

Is there any to have variable settings in the desktop version?

 

I've got a single PDF that requires 4 different composition outputs. I'm hoping to find a way to load it dynamically based on configuration/filename/anything that isn't the CSV. Ideally I'd have 1 file with 4 outputs, but it seems like I may have to have 4 files with 4 different outputs.

 

Thanks!

 

Kyle

Link to comment
Share on other sites

Thanks Dan. Isn't that the input CSV file name? E.g. MyData.csv?

Oh, sorry, I misread the question. You don't want the input data file name. You want the name of the template PDF file.

 

Unfortunately, that's a bit trickier, if not impossible. The thing is, technically, a FusionPro composition doesn't need a template PDF file. It really only needs a data file, a CFG (config/job settings file), and a DIF (format/layout) file which defines the pages and frames. (Usually you have a Data Definition [DEF] file with rules and such too, although that's not technically required either. Plus you can have a "None" input type with no data file.)

 

When you design a FusionPro template, all of the rules and resources and variable frames are indeed embedded into the template PDF. However, at composition time, the template PDF becomes merely a "background" graphic resource, which is placed into a graphic frame at a lower layer than all other frames on the page. FusionPro, which used to be called DL Formatter, was originally a plug-in to FrameMaker, where you didn't have a "background" PDF, you just had static and variable content in frames. In FusionPro, with the Acrobat plug-in, you just have one "frame" of static background content (a page of the template PDF), and some variable frames on top of that. The composition doesn't really have any concept of a "template" PDF, just a document which happens to be used in a static frame at the lowest layer on each page.

 

So there's no composition-time hook in JavaScript to get the PDF file which was the design-time "template" file. I'll have to think about this and see if I can figure out a way to get that file name.

 

I guess what I would recommend is to come up with a different way of doing what you need. In your original post, you said:

I've got a single PDF that requires 4 different composition outputs. I'm hoping to find a way to load it dynamically based on configuration/filename/anything that isn't the CSV. Ideally I'd have 1 file with 4 outputs, but it seems like I may have to have 4 files with 4 different outputs.

It sounds like you're saying you want things to work with a single PDF template file anyway, so how does knowing the name of that single PDF help you to differentiate what the rule should do on four different runs?

 

Perhaps what you want to do is roll your own background. You can simply have a blank "template" template PDF, with no background at all (or with the "Suppress static PDF background" box checked on the Graphics tab of the Composition Settings dialog. Then you can just place a big variable graphic frame at the lowest layer on each page of the template PDF, and have a series graphic of rules which do something like this to populate those "background" frames:

var r = CreateResource(Field("BackgroundPDF"));
r.pagenumber = 2; // different number for each template page
return r;

This assumes that the name of the "background" PDF is in the data.

 

Or you could have a single graphic rule with the "Re-evaluate this rule for every graphic frame" box checked, and logic something like this:

var r = CreateResource(Field("BackgroundPDF"));
r.pagenumber = FusionPro.Composition.CurrentFlow.name;
return r;

Where you name the graphic frame on each page "1", "2", "3", etc. Or you could use frame names such as "Background 1, " Background 2", etc., and write the rule like this:

var r = CreateResource(Field("BackgroundPDF"));
r.pagenumber = FusionPro.Composition.CurrentFlow.name.match(/\d+/);
return r;

Link to comment
Share on other sites

Hi Dan,

 

What we really have is a single PDF template that we need to compose in 4 different ways.

 

Option 1: Print to special paper with pre-printed background w/ PPML

Option 2: Print to normal paper with no pre-printed sheet, so I have to hide a page from option 1 and show a different page w/ PPML

Option 3: Print to separate PDF files on a per-record basis.

Option 4: Similar to option 2 with different pages and different print options w/ a different output folder.

 

So, the problem I am trying to solve is how to setup different composition options based off an identifiable piece of data that isn't part of the input CSV file. If I can figure out the PDF name, then I could make 4 copies, each with different composition options. Same rule applies for command-line options, or UI options during composition.

 

It sounds like it would be easy with the Server version, but we only have the desktop version and upgrading is not an option.

 

I welcome any ideas. Thanks for the help.

Link to comment
Share on other sites

Is there any to have variable settings in the desktop version?

It depends on what kind of settings you want to be variable. If they are settings in the CFG file (imposition, cropmarks, output format, etc) then the short answer is "no." The CFG file is read-only so you could set up some JavaScript rules to key off of their values and do different things depending on their current settings but you are not able to alter these settings since they are generated based on the output settings dialog at the start of each composition. But if you wanted to turn on page 1 if the job is imposed and page 2 if there's no imposition, you could do something like this:

// OnRecordStart Callback rule
var pg = (FusionPro.Composition.JobOptions["UseImpositionDefFile"] == "Yes") ? 1 : 2;
FusionPro.Composition.SetBodyPageUsage(pg,true);

That being said, with FPServer you'd have the capability to have multiple cfg files (one for imposed and one for unimposed for example) that you could specify on the command line:

@echo off
start cmd /C Call C:\Program Files (x86)\PTI\FusionPro\FusionPro "\\path\to\data.csv" "\\path\to\dif\[templatename].dif" "\\path\to\cfg\[templatename]_imposed-o.cfg" "\\path\to\output_imposed.pdf"
start cmd /C Call C:\Program Files (x86)\PTI\FusionPro\FusionPro "\\path\to\data.csv" "\\path\to\dif\[templatename].dif" "\\path\to\cfg\[templatename]_unimposed-o.cfg" "\\path\to\output_unimposed.pdf"

Link to comment
Share on other sites

Yeah, I need to change the output settings.. primarily folder path and file type (PPML vs PDF). Imposition stays the same for all 4.

 

Where are the cfg files located for the desktop version? I don't see them being created anywhere. I've got a .dif, .def, and .pdf. I'd like to be able to backup all 4 into our source control in case something happens.

 

Thanks!

Link to comment
Share on other sites

I'm still missing something here. You seem to be saying two different things. First you say:

What we really have is a single PDF template that we need to compose in 4 different ways.

Then you say:

If I can figure out the PDF name, then I could make 4 copies, each with different composition options.

So do you have just one PDF template, or do you have four PDF templates? If there's only one, then why do you need to figure out the name? And if there are four, then why not just set up different settings in each one?

 

Anyway, for these steps:

Option 1: Print to special paper with pre-printed background w/ PPML

Option 2: Print to normal paper with no pre-printed sheet, so I have to hide a page from option 1 and show a different page w/ PPML

Option 3: Print to separate PDF files on a per-record basis.

Option 4: Similar to option 2 with different pages and different print options w/ a different output folder.

Other than changing the output format, you could do most of that in a single composition, by reading in the data file as an external data file, repeating records, breaking up the output, and using different pages (with different JDF media settings) in OnRecordStart. The coding would be pretty complex, though, and well beyond the scope of what I can help you with here on this forum. Others are welcome to jump in, though.

So, the problem I am trying to solve is how to setup different composition options based off an identifiable piece of data that isn't part of the input CSV file.

When you say, "an identifiable piece of data that isn't part of the input CSV file," I immediately think of an external, or secondary data file. Although, as I said above, you may need to read in the "main" CSV file as an external data file, and then read this other "identifiable piece of data" from a second external data file.

If I can figure out the PDF name, then I could make 4 copies, each with different composition options. Same rule applies for command-line options, or UI options during composition.

I think you're getting stuck on the idea that the only thing you can key off of is the template PDF name.

Same rule applies for command-line options

Command-line options? I thought you were using Desktop? There are no command-line options in Desktop, only in FP Server.

or UI options during composition.

I don't know what you mean by "UI options." All of the settings from the Composition Settings dialog become entries in the CFG file.

It sounds like it would be easy with the Server version, but we only have the desktop version and upgrading is not an option.

Well, I'm not sure what you tell you here, other than that what you're talking about really is something that requires FP Server. You're trying to get across the ocean, and buying a bigger ship may not be an option, but you're not going to be able to cross the ocean with the powerful but still limited boat you have now. But you should contact Sales and see what they say. I can't promise anything, but they might be able to work out something like a reduced rate for a limited Server license. If you let me know where you're located, I can put you in touch with the sales person for your region.

Where are the cfg files located for the desktop version? I don't see them being created anywhere. I've got a .dif, .def, and .pdf. I'd like to be able to backup all 4 into our source control in case something happens.

The CFG file should be created when you compose or collect, just like the DIF and DEF files. But backing them up won't do you much good with FP Desktop; those files are generated based on the information stored in the template PDF. So it's that template PDF you need to back up.

 

What version of FusionPro are you running, and on what operating system?

Edited by Dan Korn
typo
Link to comment
Share on other sites

Where are the cfg files located for the desktop version? I don't see them being created anywhere. I've got a .dif, .def, and .pdf. I'd like to be able to backup all 4 into our source control in case something happens.

If you collect your template (FusionPro > Collect) you'll see the cfg file get created from the output settings at the time of collection.

 

Yeah, I need to change the output settings.. primarily folder path and file type (PPML vs PDF).

 

You can't change the file type with a JavaScript rule but you can change the output folder path. For example: if you want your PDF files to output to a different folder than your PPML files, you could create an OnNewOutputFile callback rule that looked like this:

var outputPath = '/path/to/PPML/outputFolder/';
if (FusionPro.Composition.JobOptions['OutputFormat'] == "PDF"){
   outputPath = '/path/to/PDF/outputFolder/';
}
FusionPro.Composition.outputFileFullPathName = outputPath;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...