I don't think it makes sense to have this. The nsIPrinter objects are for getting information about a given printer, which allows the frontend to display a bunch of possible print settings, take user input to select some of those settings, then create an nsIPrintSettings object and pass it to the backend to create the print preview/do the print. In the case of save-to-PDF it's really up to the frontend to choose what page sizes should be available to the user, what margins pages should have, etc. rather than have the backend make those sort of choices. The frontend should do something similar to the [ExtensionAPI.tabs.saveAsPDF](https://searchfox.org/mozilla-central/rev/a3b25e347e2c22207c4b369b99246e4aebf861a7/browser/components/extensions/parent/ext-tabs.js#1287) code. That is, after presenting some page options and getting the user's choices, it should open a dialog to get the path to save the PDF to, then create an nsIPrintSettings object and set the path and the other settings on that, and then also set: ``` printSettings.printSilent = true; printSettings.showPrintProgress = false; printSettings.outputFormat = Ci.nsIPrintSettings.kOutputFormatPDF; ``` and then instruct the backend to print.
Bug 1658029 Comment 1 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
I don't think it makes sense to have this. The nsIPrinter objects are for getting information about a given printer, which allows the frontend to display a bunch of possible print settings, take user input to select some of those settings, then create an nsIPrintSettings object and pass it to the backend to create the print preview/do the print. In the case of save-to-PDF it's really up to the frontend to choose what page sizes should be available to the user, what margins pages should have, etc. rather than have the backend make those sort of choices. The frontend should do something similar to the [ExtensionAPI.tabs.saveAsPDF](https://searchfox.org/mozilla-central/rev/a3b25e347e2c22207c4b369b99246e4aebf861a7/browser/components/extensions/parent/ext-tabs.js#1287) code. That is, after presenting some page options and getting the user's choices, it should open a dialog to get the path to save the PDF to, then create an nsIPrintSettings object and set the path and the other settings on that, and then also set: ``` printSettings.printSilent = true; printSettings.outputFormat = Ci.nsIPrintSettings.kOutputFormatPDF; ``` and then instruct the backend to print.