Skip to main content
Inspiring
March 31, 2025
Answered

Need a script to display print dialog

  • March 31, 2025
  • 4 replies
  • 2100 views

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:

  • Page Range - All
  • Do Not Skip Blank Pages
  • Do Not Print to File
  • Do Not Generate Acrobat Data
  • User will select the correct printer
  • Also - some of our documents use an odd paper size (8x5 inches). The documents should be printed at this size. I think the default menu picks this up from the document settings, and if not, I think it would need to be from the printer settings, but we can work around this if necessary.

Example attached:

Correct answer Marshall_Brooks

They are in the fcodes.h file that comes with the FDK. With ExtendScript you have to put the FCodes. prefix on them.


@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.)

4 replies

Jeff_Coatsworth
Community Expert
Community Expert
March 31, 2025

You guys go to town on this scripting stuff, but I still can't see the use-case for building this. Are your FM authors that bad that they can't figure out how to File > Print > make some choices & create some output? Just scratching my head....

frameexpert
Community Expert
Community Expert
March 31, 2025

In some cases, scripting can be overkill, but what if you were doing the same thing many times a day? A one-click solution could save a lot of time.

Jeff_Coatsworth
Community Expert
Community Expert
March 31, 2025

Ok, I guess - I don't think I've printed something out from my FM content in the last 6 months - oh, maybe a page or two for somebody to review. Not a high-demand action in my world. Certainly YMMV - Fill 'yer boots! 🤣

frameexpert
Community Expert
Community Expert
March 31, 2025

Documents have a bunch of printer properties that you can set. Did you try these?

Inspiring
March 31, 2025

@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 ...

frameexpert
Community Expert
Community Expert
March 31, 2025

There is a PrinterName property. Here is an example from the FDK docs.

Jeff_Coatsworth
Community Expert
Community Expert
March 31, 2025

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.

Inspiring
March 31, 2025

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!

Inspiring
March 31, 2025

Image isn't uploading for me ...

Image: https://github.com/Marshall-Brooks/Sandbox/issues/1