Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/HTMLViewer Mac/HTMLViewer PDF Save and Print
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/HTMLViewer PDF Save and Print
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/HTMLViewer PDF Save and Print
Project "HTMLViewer PDF Save and Print.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
End Control
Control SaveButton Inherits PushButton
ControlInstance SaveButton Inherits PushButton
EventHandler Sub Action()
// save PDF in HTMLViewer on MacOS to disk
Dim dataSource As WebDataSourceMBS = HTMLViewer1.mainFrameMBS.dataSource
Dim data As String = dataSource.data
Dim mainResource As WebResourceMBS = dataSource.mainResource
// get file name
Dim url As New NSURLMBS(mainResource.URL)
Dim name As String = url.lastPathComponent
// write file to location
Dim f As FolderItem = GetSaveFolderItem("", name)
If f <> Nil then
Dim b As BinaryStream = BinaryStream.Create(f)
b.Write data
End If
End EventHandler
End Control
Control PrintButton Inherits PushButton
ControlInstance PrintButton Inherits PushButton
EventHandler Sub Action()
// print PDF in HTMLViewer on MacOS
Dim dataSource As WebDataSourceMBS = HTMLViewer1.mainFrameMBS.dataSource
Dim data As MemoryBlock = dataSource.data
Dim doc As New PDFDocumentMBS(data)
// Dim PrintInfo As New NSPrintInfoMBS
Dim PrintInfo As NSPrintInfoMBS = NSPrintInfoMBS.sharedPrintInfo
Dim op As NSPrintOperationMBS = doc.PrintOperation(PrintInfo)
op.showsPrintPanel = True
op.showsProgressPanel = True
op.runOperationModalForWindow Self
End EventHandler
End Control
EventHandler Sub Open()
HTMLViewer1.LoadURL "https://www.monkeybreadsoftware.de/xojo/download/plugin/Installation.pdf"
End EventHandler
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
See also:
- /MacControls/HTMLViewer Mac/HTML Editor Mac
- /MacControls/HTMLViewer Mac/HTML5 Video/htmlviewer with html5 video
- /MacControls/HTMLViewer Mac/HTMLViewer Extensions
- /MacControls/HTMLViewer Mac/HTMLViewer get html source
- /MacControls/HTMLViewer Mac/HTMLViewer Image
- /MacControls/HTMLViewer Mac/HTMLViewer on TabPanels fix
- /MacControls/HTMLViewer Mac/JavaScript callback test
- /MacControls/HTMLViewer Mac/Mac Cookies
- /MacControls/HTMLViewer Mac/Open Link in iTunes
- /MacControls/HTMLViewer Mac/WebUIDelegate
The items on this page are in the following plugins: MBS MacControls Plugin.
Feedback: Report problem or ask question.