-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
117e6ca
commit e71eeb6
Showing
1 changed file
with
63 additions
and
48 deletions.
There are no files selected for viewing
111 changes: 63 additions & 48 deletions
111
src/mzkit/mzkit/pages/dockWindow/documents/frmHtmlViewer.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,79 @@ | ||
#Region "Microsoft.VisualBasic::cfb956a25f80777b1be73f0a791b5ad8, pages\dockWindow\documents\frmHtmlViewer.vb" | ||
|
||
' Author: | ||
' | ||
' xieguigang ([email protected], BioNovoGene Co., LTD.) | ||
' | ||
' Copyright (c) 2018 [email protected], BioNovoGene Co., LTD. | ||
' | ||
' | ||
' MIT License | ||
' | ||
' | ||
' Permission is hereby granted, free of charge, to any person obtaining a copy | ||
' of this software and associated documentation files (the "Software"), to deal | ||
' in the Software without restriction, including without limitation the rights | ||
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
' copies of the Software, and to permit persons to whom the Software is | ||
' furnished to do so, subject to the following conditions: | ||
' | ||
' The above copyright notice and this permission notice shall be included in all | ||
' copies or substantial portions of the Software. | ||
' | ||
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
' SOFTWARE. | ||
|
||
|
||
|
||
' /********************************************************************************/ | ||
|
||
' Summaries: | ||
|
||
' Class frmHtmlViewer | ||
' | ||
' Sub: frmHtmlViewer_Load, LoadHtml, PDF, SavePDFToolStripMenuItem_Click, WebBrowser1_DocumentCompleted | ||
' | ||
' /********************************************************************************/ | ||
' Author: | ||
' | ||
' xieguigang ([email protected], BioNovoGene Co., LTD.) | ||
' | ||
' Copyright (c) 2018 [email protected], BioNovoGene Co., LTD. | ||
' | ||
' | ||
' MIT License | ||
' | ||
' | ||
' Permission is hereby granted, free of charge, to any person obtaining a copy | ||
' of this software and associated documentation files (the "Software"), to deal | ||
' in the Software without restriction, including without limitation the rights | ||
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
' copies of the Software, and to permit persons to whom the Software is | ||
' furnished to do so, subject to the following conditions: | ||
' | ||
' The above copyright notice and this permission notice shall be included in all | ||
' copies or substantial portions of the Software. | ||
' | ||
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
' SOFTWARE. | ||
|
||
|
||
|
||
' /********************************************************************************/ | ||
|
||
' Summaries: | ||
|
||
' Class frmHtmlViewer | ||
' | ||
' Sub: frmHtmlViewer_Load, LoadHtml, PDF, SavePDFToolStripMenuItem_Click, WebBrowser1_DocumentCompleted | ||
' | ||
' /********************************************************************************/ | ||
|
||
#End Region | ||
|
||
Imports mzkit.My | ||
Imports WkHtmlToPdf.Arguments | ||
|
||
Public Class frmHtmlViewer | ||
|
||
Dim url As String | ||
|
||
Public Sub PDF(filepath As String) | ||
Dim env As New PdfConvertEnvironment With { | ||
.Debug = False, | ||
.TempFolderPath = App.GetAppSysTempFile, | ||
.Timeout = 60000, | ||
.WkHtmlToPdfPath = $"{App.HOME}/wkhtmltopdf.exe" | ||
} | ||
Dim content As New PdfDocument With {.Url = {WebBrowser1.Url.OriginalString}} | ||
Dim pdfFile As New PdfOutput With {.OutputFilePath = filepath} | ||
Static bin As String = Nothing | ||
|
||
If bin.StringEmpty Then | ||
bin = $"{App.HOME}/tools/wkhtmltopdf.exe" | ||
|
||
Call WkHtmlToPdf.PdfConvert.ConvertHtmlToPdf(content, pdfFile, env) | ||
If Not bin.FileExists Then | ||
bin = $"{App.HOME}/wkhtmltopdf.exe" | ||
End If | ||
End If | ||
|
||
If bin.FileExists Then | ||
Dim env As New PdfConvertEnvironment With { | ||
.Debug = False, | ||
.TempFolderPath = App.GetAppSysTempFile, | ||
.Timeout = 60000, | ||
.WkHtmlToPdfPath = bin | ||
} | ||
Dim content As New PdfDocument With {.Url = {WebBrowser1.Url.OriginalString}} | ||
Dim pdfFile As New PdfOutput With {.OutputFilePath = filepath} | ||
|
||
Call WkHtmlToPdf.PdfConvert.ConvertHtmlToPdf(content, pdfFile, env) | ||
Else | ||
Call MyApplication.host.showStatusMessage("'wkhtmltopdf' tool is missing for generate PDF file...", My.Resources.StatusAnnotations_Warning_32xLG_color) | ||
End If | ||
End Sub | ||
|
||
Public Sub LoadHtml(url As String) | ||
|