I have a GitHub repository , which allows the user to save paginated PDF on Mac in some the HTML, loading it in a WebView and use NSPrintOperation(in particular, NSPrintSaveJobto showsPrintPanelset to false) allows the user to save this PDF anywhere on your Mac using the save panel is similar in by default NSSavePanel. However, I am experimenting with the code, and I would like instead to save the saved PDF file to a specific folder ( /Users/owlswipe/Downloads/) without a save panel.
My code for saving a PDF file from WebView (with a save panel) currently looks like this:
let printOpts: [String : AnyObject] = [NSPrintJobDisposition:NSPrintSaveJob as AnyObject]
let printInfo: NSPrintInfo = NSPrintInfo(dictionary: printOpts)
printInfo.paperSize = NSMakeSize(595.22, 841.85)
let printOp: NSPrintOperation = NSPrintOperation(view: webView.mainFrame.frameView.documentView, printInfo: printInfo)
printOp.showsPrintPanel = false
printOp.showsProgressPanel = false
printOp.run()
How can I adapt this code to save the PDF file to a folder with a preinstalled program, and not to select folders from the save panel by the user?
source
share