Hi,
If I open a PDF document in HTMLViewer and want to print that document using the print method, the app does not print the document, but only the HTMLViewer itself as it shows on the screen. How can I print an entire PDF document from the HTMLViewer?
Desktop or Web? Mac/Win/Linux?
I just made a new sample project here for next prerelease.
First save the PDF:
[code]// 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[/code]
Check WebDataSourceMBS, WebResourceMBS and NSURLMBS classes in our documentation.
second print the PDF with PDFDocumentMBS class in PDFKit and NSPrintOperationMBS class.
[code]// 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[/code]