Anhangsimport - Bugfix

This commit is contained in:
2024-10-11 13:19:04 +02:00
parent a7996287d1
commit aea776a71f

View File

@@ -1,16 +1,10 @@
 
'Imports iTextSharp.text.pdf Imports itextsharp.text
'Imports iTextSharp.text
Imports System.IO Imports System.IO
Imports Spire.Pdf Imports Spire.Pdf
Imports Spire.Pdf.Conversion
Imports Spire.Pdf.Conversion.Compression Imports Spire.Pdf.Conversion.Compression
Imports Spire.Pdf.Exporting Imports Spire.Pdf.Exporting
Imports VERAG_PROG_ALLGEMEIN Imports VERAG_PROG_ALLGEMEIN
'Imports GrapeCity.Documents.Pdf
'Imports Spire.Pdf
Public Class frmSendungAnhangImport Public Class frmSendungAnhangImport
@@ -148,9 +142,16 @@ Public Class frmSendungAnhangImport
WebBrowser.Visible = (loc <> "") WebBrowser.Visible = (loc <> "")
WebBrowser.Navigate(loc) WebBrowser.Navigate(loc)
Else Else
WebBrowser.Visible = False WebBrowser.Visible = False
PdfViewer.Visible = (loc <> "") PdfViewer.Visible = (loc <> "")
PdfViewer.LoadFromFile(loc)
Dim data = File.ReadAllBytes(loc)
Dim pdfStream = New MemoryStream(data)
PdfViewer.LoadFromStream(pdfStream)
'NOT WORKING
'PdfViewer.LoadFromFile(loc) NOT WORKING
End If End If
ElseIf typ = "BILD" Then ElseIf typ = "BILD" Then
PdfViewer.Visible = False PdfViewer.Visible = False
@@ -494,7 +495,7 @@ Public Class frmSendungAnhangImport
Try Try
PagesLeft = 0 PagesLeft = 0
Dim pdf As New PdfDocument() Dim pdf As New Spire.Pdf.PdfDocument()
pdf.LoadFromFile(sourceFile) pdf.LoadFromFile(sourceFile)
' Dim r As PdfReader = New PdfReader(sourceFile) ' Dim r As PdfReader = New PdfReader(sourceFile)
Dim pagesToKeep As New List(Of Integer) Dim pagesToKeep As New List(Of Integer)
@@ -511,7 +512,7 @@ Public Class frmSendungAnhangImport
Next Next
Dim pdf1 As New PdfDocument() Dim pdf1 As New Spire.Pdf.PdfDocument()
Dim page As PdfPageBase Dim page As PdfPageBase
For Each p In pagesToKeep For Each p In pagesToKeep
@@ -580,10 +581,10 @@ Public Class frmSendungAnhangImport
Dim pdf As New PdfDocument() Dim pdf As New Spire.Pdf.PdfDocument()
pdf.LoadFromFile(sourceFile) pdf.LoadFromFile(sourceFile)
Dim pdf1 As New PdfDocument() Dim pdf1 As New Spire.Pdf.PdfDocument()
Dim page As PdfPageBase Dim page As PdfPageBase
For Each p In pagesToExtract For Each p In pagesToExtract
@@ -658,7 +659,7 @@ Public Class frmSendungAnhangImport
Dim Reader As New iTextSharp.text.pdf.PdfReader(SourceFile) Dim Reader As New iTextSharp.text.pdf.PdfReader(SourceFile)
If Not TargetFile.ToLower.EndsWith(".pdf") Then TargetFile = TargetFile & ".pdf" If Not TargetFile.ToLower.EndsWith(".pdf") Then TargetFile = TargetFile & ".pdf"
Dim srcDoc As New iTextSharp.text.Document() 'Reader.GetPageSizeWithRotation(0)) Dim srcDoc As New iTextSharp.text.Document() 'Reader.GetPageSizeWithRotation(0))
Dim PdfCopyProvider As New iTextSharp.text.pdf.PdfCopy(srcDoc, New System.IO.FileStream(TargetFile, System.IO.FileMode.Create)) Dim PdfCopyProvider As New itextsharp.text.pdf.PdfCopy(srcDoc, New FileStream(TargetFile, System.IO.FileMode.Create))
PdfCopyProvider.SetFullCompression() PdfCopyProvider.SetFullCompression()
srcDoc.Open() srcDoc.Open()
For Each p In pagesToExtract For Each p In pagesToExtract
@@ -1083,7 +1084,7 @@ Public Class frmSendungAnhangImport
compressor.CompressToFile(DS.GET_TOP1_PATH) compressor.CompressToFile(DS.GET_TOP1_PATH)
'Load the pdf document 'Load the pdf document
Dim doc As New PdfDocument() Dim doc As New Spire.Pdf.PdfDocument()
doc.LoadFromFile(DS.GET_TOP1_PATH) doc.LoadFromFile(DS.GET_TOP1_PATH)
'Compress the content in document 'Compress the content in document
@@ -1107,7 +1108,7 @@ Public Class frmSendungAnhangImport
End If End If
Return False Return False
End Function End Function
Private Shared Sub CompressContent(ByVal doc As PdfDocument) Private Shared Sub CompressContent(ByVal doc As Spire.Pdf.PdfDocument)
'Disable the incremental update 'Disable the incremental update
doc.FileInfo.IncrementalUpdate = False doc.FileInfo.IncrementalUpdate = False
@@ -1115,7 +1116,7 @@ Public Class frmSendungAnhangImport
doc.CompressionLevel = PdfCompressionLevel.Best doc.CompressionLevel = PdfCompressionLevel.Best
End Sub End Sub
Private Shared Sub CompressImage(ByVal doc As PdfDocument) Private Shared Sub CompressImage(ByVal doc As Spire.Pdf.PdfDocument)
Try Try
'Disable the incremental update 'Disable the incremental update
doc.FileInfo.IncrementalUpdate = False doc.FileInfo.IncrementalUpdate = False
@@ -1625,7 +1626,7 @@ Public Class frmSendungAnhangImport
' Dim F_listItem As String = Path.Combine("c:\mynewpath", Path.GetFileName(s)) ' Dim F_listItem As String = Path.Combine("c:\mynewpath", Path.GetFileName(s))
' File.Copy(s, newFile) ' File.Copy(s, newFile)
' MsgBox(s) ' MsgBox(s)
If IO.File.Exists(s) Then If System.IO.File.Exists(s) Then
Dim fi As New FileInfo(s) Dim fi As New FileInfo(s)
Dim filename = fi.Name Dim filename = fi.Name
@@ -1827,7 +1828,7 @@ Public Class frmSendungAnhangImport
If u.FILE_TYPE <> "PDF" Then Exit Sub If u.FILE_TYPE <> "PDF" Then Exit Sub
' Dim fi As New FileInfo(u.FILE_PATH) ' Dim fi As New FileInfo(u.FILE_PATH)
Dim pdf As New PdfDocument() Dim pdf As New Spire.Pdf.PdfDocument()
pdf.LoadFromFile(u.FILE_PATH) pdf.LoadFromFile(u.FILE_PATH)
For Each p In pdf.Pages For Each p In pdf.Pages
txtSeiten.Text = "1" txtSeiten.Text = "1"
@@ -2061,7 +2062,7 @@ Public Class frmSendungAnhangImport
Try Try
' We have a embedded file. First lets try to get the file name out of memory ' We have a embedded file. First lets try to get the file name out of memory
Dim theStream As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream) Dim theStream As System.IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), System.IO.Stream)
Dim fileGroupDescriptor(512) As Byte Dim fileGroupDescriptor(512) As Byte
theStream.Read(fileGroupDescriptor, 0, 512) theStream.Read(fileGroupDescriptor, 0, 512)
Dim fileName As System.Text.StringBuilder = New System.Text.StringBuilder("") Dim fileName As System.Text.StringBuilder = New System.Text.StringBuilder("")
@@ -2074,7 +2075,7 @@ Public Class frmSendungAnhangImport
theStream.Close() theStream.Close()
' We should have the file name or if its an email, the subject line. Create our temp file based on the temp path and this info ' We should have the file name or if its an email, the subject line. Create our temp file based on the temp path and this info
Dim myTempFile As String = IO.Path.GetTempPath & VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(fileName.ToString) Dim myTempFile As String = System.IO.Path.GetTempPath & VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(fileName.ToString)
' Look to see if this is a email message. If so save that temporarily and get the temp file. ' Look to see if this is a email message. If so save that temporarily and get the temp file.
If InStr(myTempFile, ".msg") > 0 Then If InStr(myTempFile, ".msg") > 0 Then
@@ -2091,19 +2092,19 @@ Public Class frmSendungAnhangImport
objMI = Nothing objMI = Nothing
Else Else
' If its a attachment we need to pull the file itself out of memory ' If its a attachment we need to pull the file itself out of memory
Dim ms As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream) Dim ms As System.IO.MemoryStream = CType(e.Data.GetData("FileContents", True), System.IO.MemoryStream)
Dim FileBytes(CInt(ms.Length)) As Byte Dim FileBytes(CInt(ms.Length)) As Byte
' read the raw data into our variable ' read the raw data into our variable
ms.Position = 0 ms.Position = 0
ms.Read(FileBytes, 0, CInt(ms.Length)) ms.Read(FileBytes, 0, CInt(ms.Length))
ms.Close() ms.Close()
' save the raw data into our temp file ' save the raw data into our temp file
Dim fs As IO.FileStream = New IO.FileStream(myTempFile, IO.FileMode.OpenOrCreate, IO.FileAccess.Write) Dim fs As System.IO.FileStream = New System.IO.FileStream(myTempFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write)
fs.Write(FileBytes, 0, FileBytes.Length) fs.Write(FileBytes, 0, FileBytes.Length)
fs.Close() fs.Close()
End If End If
' Make sure we have a actual file and also if we do make sure we erase it when done ' Make sure we have a actual file and also if we do make sure we erase it when done
If IO.File.Exists(myTempFile) Then If System.IO.File.Exists(myTempFile) Then
' Assign the file name to the add dialog ' Assign the file name to the add dialog
EmAilAttach = myTempFile EmAilAttach = myTempFile
Else Else