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

Need a script to display print dialog

Engaged ,
Mar 31, 2025 Mar 31, 2025

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:

TOPICS
Scripting
684
Translate
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

correct answers 3 Correct answers

Community Expert , Mar 31, 2025 Mar 31, 2025

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

image.pngexpand image

Translate
Community Expert , Mar 31, 2025 Mar 31, 2025

This works:

Fcodes ([FCodes.KBD_PRINT]);
Translate
Engaged , Apr 01, 2025 Apr 01, 2025

@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

...
Translate
Engaged ,
Apr 01, 2025 Apr 01, 2025

@Jeff_Coatsworth - I'll check into it. Managed corporate install, so it might take a while. I remember it installed with FM 11, and it seems odd that Adobe would charge $$$ for FrameMaker but then to create PDF's you have to pay $$$ for Acrobat or use 3rd-party solutions.

Translate
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 ,
Mar 31, 2025 Mar 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....

Translate
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 ,
Mar 31, 2025 Mar 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.

Translate
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 ,
Mar 31, 2025 Mar 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! 🤣

Translate
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
Engaged ,
Mar 31, 2025 Mar 31, 2025

@Jeff_Coatsworth:

 

You'd be surprised - but I've been burned by it myself sometimes.

 

  • Pretty easy to not check "All pages" b/c the default is the current page, and then the lead gets a 1-page document to review. Then the writer has to make a new PDF to submit to the lead, etc.
  • Additional reason is this will be called from a different script. So no need to pop-up a message with "Changes implemented, please create PDF's now). No need for the user to have to click Ctrl-P and verify the settings are correct, etc.
Translate
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
Engaged ,
May 08, 2025 May 08, 2025

@frameexpert - I'm back to this with two questions:

 

First, how can I set the PrinterName.

doc.PrinterName = "Microsoft Print to PDF";

doesn't generate an error, but seems to be ignored.

The code you posted earlier:

F_ObjHandleT docId;
docID = F_ApiGetID(0, FV_SessionID, FP_ActiveDoc);
F_ApiSetString(FV_SessionID, docID, FP_PrinterName, "ps11");

Gives me an error of  "Expected: ;" on the first line, but I don't know where it thinks the ; belongs.

 

Second question: Since I cant set the printername, I can't test what happens if I set it to something that doesn't exist, but I assume it would give me an error when I tried to print. How can I query what printers are installed?

 

I'm looking for something similar to:

 

If (doc.PrinterName="Adobe PDF".objectValid){

  doc.PrinterName = "Adobe PDF";

}

else if (doc.PrinterName="Power PDF".objectValid){

   doc.PrinterName = "Power PDF";

}

 

Obviously none of the code above works, but basically, if Adobe PDF is available, set the printer to that, if not, set the Printer to Power PDF, if not, set the printer to Microsoft Print to PDF, if not, let the user decide.

Translate
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
Engaged ,
May 12, 2025 May 12, 2025
LATEST

Per the documentation, doc.PrinterName has no effect on Windows - presumably it works on Macintosh (or Linux?).

Translate
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