Verzollungspreise, Formulare, USTVA, etc.
This commit is contained in:
@@ -1547,7 +1547,7 @@ Public Class cFormularManager
|
||||
|
||||
|
||||
|
||||
Public Shared Function getPDFViaSpirePDF_FromURLStream(URL As String, Optional filename As String = "", Optional targetPath As String = "", Optional openFileAfterDownload As Boolean = True) As String
|
||||
Public Shared Function getPDFViaSpirePDF_FromURLStream(URL As String, Optional filename As String = "", Optional targetPath As String = "", Optional openFileAfterDownload As Boolean = True, Optional showError As Boolean = True) As String
|
||||
Try
|
||||
If targetPath = "" Then
|
||||
If filename <> "" Then
|
||||
@@ -1584,10 +1584,78 @@ Public Class cFormularManager
|
||||
|
||||
Return targetPath
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name, IIf(Not showError, "LOG", ""))
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function getFile_FromURLStream(URL As String, Optional filename As String = "", Optional targetPath As String = "", Optional showError As Boolean = True) As String
|
||||
Try
|
||||
Using webClient As New Net.WebClient()
|
||||
|
||||
' Download data
|
||||
Dim data() As Byte = webClient.DownloadData(URL)
|
||||
|
||||
' Read Content-Type header
|
||||
Dim contentType As String = webClient.ResponseHeaders("Content-Type")
|
||||
|
||||
If contentType IsNot Nothing Then
|
||||
contentType = contentType.ToLower()
|
||||
Else
|
||||
contentType = ""
|
||||
End If
|
||||
|
||||
' Determine extension from Content-Type
|
||||
Dim extension As String = ""
|
||||
|
||||
If contentType.Contains("pdf") Then
|
||||
extension = ".pdf"
|
||||
|
||||
ElseIf contentType.Contains("excel") OrElse contentType.Contains("spreadsheetml") OrElse contentType.Contains("ms-excel") Then
|
||||
|
||||
' xlsx or xls
|
||||
If contentType.Contains("spreadsheetml") Then
|
||||
extension = ".xlsx"
|
||||
Else
|
||||
extension = ".xls"
|
||||
End If
|
||||
End If
|
||||
|
||||
' Build target path
|
||||
Dim fullPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename & extension)
|
||||
|
||||
' Handle based on file type
|
||||
If extension = ".pdf" Then
|
||||
|
||||
Using stream As New MemoryStream(data)
|
||||
Dim doc As New Spire.Pdf.PdfDocument()
|
||||
doc.LoadFromStream(stream)
|
||||
doc.SaveToFile(fullPath)
|
||||
targetPath = fullPath
|
||||
|
||||
End Using
|
||||
|
||||
ElseIf extension = ".xls" OrElse extension = ".xlsx" Then
|
||||
System.IO.File.WriteAllBytes(fullPath, data)
|
||||
targetPath = fullPath
|
||||
Else
|
||||
' Unknown file type – save raw
|
||||
fullPath = fullPath & ".bin"
|
||||
System.IO.File.WriteAllBytes(fullPath, data)
|
||||
End If
|
||||
|
||||
End Using
|
||||
|
||||
|
||||
|
||||
Return targetPath
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name, IIf(Not showError, "LOG", ""))
|
||||
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