getPDFfromURLStream
This commit is contained in:
@@ -7,6 +7,11 @@ Imports System.Runtime.InteropServices
|
||||
Imports System.Windows.Forms
|
||||
Imports System.Drawing
|
||||
Imports Spire.Pdf.Print
|
||||
Imports Spire.Pdf
|
||||
Imports Spire.Pdf.HtmlConverter
|
||||
Imports System.Threading
|
||||
Imports System.Net
|
||||
Imports Spire.Pdf.Tables
|
||||
|
||||
|
||||
Public Class cDATENSERVER
|
||||
@@ -1332,12 +1337,15 @@ Public Class cFormularManager
|
||||
|
||||
|
||||
|
||||
Public Shared Function getPDFViaSpirePDF_FromURL(URL As String, Optional targetPath As String = "", Optional openFileAfterDownload As Boolean = False) As String
|
||||
Public Shared Function getPDFViaSpirePDF_FromURL(URL As String, Optional targetPath As String = "") As String
|
||||
Try
|
||||
If targetPath = "" Then targetPath = getTMPPath_PDF()
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cProgramFunctions.spireLoadLicense()
|
||||
Dim doc As New Spire.Pdf.PdfDocument '= New Spire.Pdf.PdfDocument(URL)
|
||||
|
||||
|
||||
|
||||
doc.LoadFromHTML(URL, True, True, True)
|
||||
If doc IsNot Nothing Then
|
||||
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
|
||||
@@ -1348,28 +1356,9 @@ Public Class cFormularManager
|
||||
doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True)
|
||||
' doc.PrinterName = printerName
|
||||
' doc.PrintDocument.Print()
|
||||
doc.SaveToFile(targetPath)
|
||||
|
||||
End If
|
||||
|
||||
'For Each doc As Spire.Pdf.PdfDocument In docs
|
||||
'Dim doc As New Spire.Pdf.PdfDocument()
|
||||
|
||||
'Using webClient As New Net.WebClient()
|
||||
' Dim data() As Byte = webClient.DownloadData(URL)
|
||||
' Using stream As New MemoryStream(data)
|
||||
' Dim doc As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument(stream)
|
||||
' If doc IsNot Nothing Then
|
||||
' doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
|
||||
' doc.PrintDocument.DefaultPageSettings.Landscape = True
|
||||
' doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize
|
||||
' ' doc.PrinterName = printerName
|
||||
' ' doc.PrintDocument.Print()
|
||||
' doc.SaveToFile(targetPath)
|
||||
' End If
|
||||
' End Using
|
||||
'End Using
|
||||
|
||||
' doc.LoadFromHTML(pdfPath, True, True, True)
|
||||
|
||||
|
||||
Return targetPath
|
||||
@@ -1380,6 +1369,33 @@ Public Class cFormularManager
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Public Shared Function getPDFViaSpirePDF_FromURLStream(URL As String, Optional targetPath As String = "", Optional openFileAfterDownload As Boolean = True) As String
|
||||
Try
|
||||
If targetPath = "" Then targetPath = getTMPPath_PDF()
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cProgramFunctions.spireLoadLicense()
|
||||
|
||||
Using webClient As New Net.WebClient()
|
||||
Dim data() As Byte = webClient.DownloadData(URL)
|
||||
Using stream As New MemoryStream(data)
|
||||
Dim doc As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument(stream)
|
||||
If doc IsNot Nothing Then
|
||||
doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4
|
||||
doc.SaveToFile(targetPath)
|
||||
If openFileAfterDownload Then
|
||||
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Return targetPath
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
Public Shared Sub PrintViaGS(PDFFile As String, printerName As String)
|
||||
Try
|
||||
Dim assembly = System.Reflection.Assembly.GetExecutingAssembly()
|
||||
|
||||
Reference in New Issue
Block a user