I’ve been trying to crack a printing problem with a webview object. My project uses the document-based Applescript template, but has multiple NIBs: one of the NIBs has a webview which displays a HTML report and is working fine.
The problem comes when trying to print the contents of the webview. When using the menu ‘Print’ then web view needs to be clicked before it will print the complete contents - trying to set the focus to the webview using
set first responder of window "Reporter" to view "Rreportview" of window "Reporter"
results in a screenshot being printed, until the the webview is double-clicked and then the print menu works.
Using a button on the window to start the print process results in only the visible part of the view being printed. My code is
set theView to view "Rreportview" of window "Reporter"
tell theView
set sharedPrintInfo to call method "sharedPrintInfo" of class "NSPrintInfo"
call method "setLeftMargin:" of sharedPrintInfo with parameters {36.0}
call method "setRightMargin:" of sharedPrintInfo with parameters {36.0}
call method "setTopMargin:" of sharedPrintInfo with parameters {36.0}
call method "setBottomMargin:" of sharedPrintInfo with parameters {36.0}
call method "setOrientation:" of sharedPrintInfo with parameters {1}
call method "setVerticalPagination:" of sharedPrintInfo with parameters {0}
call method "setVerticallyCentered:" of sharedPrintInfo with parameters {0}
set thePrintOp to (call method "printOperationWithView:printInfo:" of class "NSPrintOperation" with parameters {theView, sharedPrintInfo})
call method "runOperation" of thePrintOp
end tell
I’d really appreciate any suggestions as I’ve run out of ideas.
Regards
Paul