Copy link to clipboard
Copied
FrameMaker 2022. Should be simple, but I couldn't find an example.
I don't want to use File>Save as PDF. Some of our authors don't have the Adobe PDF printer and it errors out, and I've also had it hang sometimes.
I don't want to use Doc.SilentPrintDoc() b/c we don't always use the defaults, and also the selected printer might be Adobe PDF, Power PDF, Microsoft Print to PDF, and that might NOT be the default printer on the users system.
I thought Fcodes([FCodes.KbdPrint]); would at least bring up the menu, but it doesn't seem to.
Ideallly, what I want is to display the menu with the following settings:
Example attached:
Documents have a bunch of printer properties that you can set. Did you try these?
This works:
Fcodes ([FCodes.KBD_PRINT]);
@frameexpert- Got it, but it wasn't easy. For me, I went to https://adobe.fandom.com/wiki/Adobe_FrameMaker_Developer_Kit - follow the link to https://web.archive.org/web/20181023130035/https://www.adobe.com/devnet/framemaker.html - That downloads, but it gets 182 of 183 MB and fails with a network errror, but it leaves a .zip.part file. Rename that to .zip and you can open it and the file is inside the zip at \products\FDK\FDK15.zip\1\Application\include.
I'm attaching it here, unless that isn't
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In FM2022, Save As PDF and Publish to PDF both use the same new PDF creation tool. Print to PDF is the only thing that uses the older Windows printer instance.
Copy link to clipboard
Copied
Okay - I don't want to use Save As PDF or Publish to PDF. How would I code a script to automate the Print to PDF interface? Thanks!
Copy link to clipboard
Copied
Documents have a bunch of printer properties that you can set. Did you try these?
Copy link to clipboard
Copied
@frameexpert - No, not yet. I saw some of those, but I wasn't sure if I just typed doc.printblankpages=1 or if I had to use a GetProps/SetProps menu, and I didn't see how to bring up the print dialog, which I need to select the printer ...
Copy link to clipboard
Copied
There is a PrinterName property. Here is an example from the FDK docs.
Copy link to clipboard
Copied
Again, for some authors, the printer name will be "Adobe PDF", for others it will be "Power PDF", for others, it will be "Microsoft Print to PDF". I'm not sure how to set one of those, test for error, set the other one if error.
Really, I just want to pull up the print dialog, but if I can preset the values that can be controlled, that would be a huge plus.
Copy link to clipboard
Copied
You could test for app.UserName and based on the user, select the appropriate printer. Or, you could present a scrollbox with all the printer names and have the user select the appropriate printer.
Copy link to clipboard
Copied
Scrollbox can work! (Is there no easy way to show the diaglog with properties selected?).
Copy link to clipboard
Copied
I would have suggested the FCode, but you tried it and it didn't work?
Copy link to clipboard
Copied
Thanks - KbdPrint might have been incorrect, I was using an old document for reference.
Specifically this: https://framescr.com/Downloads/ElmScript/RefManual.pdf - Page 328
Copy link to clipboard
Copied
This works:
Fcodes ([FCodes.KBD_PRINT]);
Copy link to clipboard
Copied
Indeed - it does!!! Thank you!!! (I'll try the other settings also)!
Copy link to clipboard
Copied
Script was very simple:
var doc = app.ActiveDoc;
doc.PrintBlankPages = 1;
doc.PrintScope = 1;
doc.GenerateAcrobatInfo = 0;
//doc.PrintPaperWidth = 5;
//doc.PrintPaperHeight = 8;
Fcodes([FCodes.KBD_PRINT]);I ended up with one minor problem, but I can live with it.
Some of our documents are printed on 5-inch wide by 8-inch high pages.
If I use FIle>Save As PDF, FM sets the paper size correctly, but that gives an error if the Adobe PDF printer is not installed.
If I set it in code like the commented lines above, it seems to be ignored.
If I go to the Print Document menu, and select Printer>Setup>Properties>Layout>Advanced>Paper Size>PostScript Custom Page Size>Edit Custom Page Size and set it to 5 x 8, and then set Paper Size to "PostScript Custom Page Size", it works, but then I have to set it back to Letter for 8.5x11 documents.
But I'm not sure there is a way to automate this. https://community.adobe.com/t5/framemaker-discussions/create-print-pdf-using-extendscript/m-p/138964... - looks like it didn't work here either.
@frameexpert - Do you know what the values should be? - from the other thread, if 54059448 = 291mm, I don't think 5 = 5 inches.
Copy link to clipboard
Copied
If it did the math correctly, 5x8 should be 36565 x 58504. If so, it doesn't work ...
Copy link to clipboard
Copied
5 inches would be 5 * 65536 * 72 but setting these values didn't work for me.
Copy link to clipboard
Copied
Thank you for testing - my numbers were way off, but it looks like it can't be done this way anyway!!!
Copy link to clipboard
Copied
I guess I would go ahead and install the Adobe PDF Printer so you can use Save As PDF programmatically.
Or, you can programmatically call the Publish command with a series of CallClient commands:
// Absolute path to .sts file.
setSts (sts);
// Absolute path to output folder.
setOutputFolder (name);
// Output type.
callPublisher ("PDF");
function setSts (sts) {
var cmd = "SetMCPSetting " + sts;
return CallClient ("FMPublisher", cmd);
}
function setOutputFolder (folder) {
var cmd = "SetOutputLocation " + folder;
return CallClient ("FMPublisher", cmd);
}
function callPublisher (type) {
var cmd = "MCPPublish " + type;
return CallClient ("FMPublisher", cmd);
}
Copy link to clipboard
Copied
Adobe PDF Printer can only be installed with a full version of Acrobat, correct?
Will those publish commands above work without the Adobe PDF Printer? File>Save As PDF gave errors.
Copy link to clipboard
Copied
Try File > Publish manually. If it works there, the publish commands should work.
Copy link to clipboard
Copied
No luck - but learned something new. Publish requires either Adobe PDF Printer or Adobe Distiller 5.0.5 or later, but from what I can tell, neither one can be installed without a full version of Acrobat (most online references say Acrobat Pro, but I think Standard includes it also - I know it does for the Adobe PDF Printer).
I'm just going to show an alert to select the custom paper size for the 5x8 documents.
@frameexpert - Where did you find the KBD_PRINT fcode? I could use an updated list, unless it was just trial and error?
Thank you again!
Copy link to clipboard
Copied
They are in the fcodes.h file that comes with the FDK. With ExtendScript you have to put the FCodes. prefix on them.
Copy link to clipboard
Copied
@frameexpert- Got it, but it wasn't easy. For me, I went to https://adobe.fandom.com/wiki/Adobe_FrameMaker_Developer_Kit - follow the link to https://web.archive.org/web/20181023130035/https://www.adobe.com/devnet/framemaker.html - That downloads, but it gets 182 of 183 MB and fails with a network errror, but it leaves a .zip.part file. Rename that to .zip and you can open it and the file is inside the zip at \products\FDK\FDK15.zip\1\Application\include.
I'm attaching it here, unless that isn't permissible. (Posted to the GitHub Link above - attachments aren't working for me.)
Copy link to clipboard
Copied
FM2022 should have installed an "AdobePDF" printer instance in Windows even if you haven't got the full Acrobat install. That being said, there are a number of threads about the Adobe PDF printer going AWOL from people's systems & instructions on getting it back.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more