pdf merge
This commit is contained in:
@@ -8,6 +8,9 @@ Imports System.Reflection
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Windows.Documents
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
Imports com.sun.tools.internal.ws.wsdl.document.mime
|
||||
Imports com.sun.xml.internal.ws.message.stream
|
||||
|
||||
Public Class frmFormulare
|
||||
Dim isSingleForm = False
|
||||
Event ShownFIN()
|
||||
@@ -6527,8 +6530,11 @@ Public Class FormularManagerNEU
|
||||
If file.ToUpper.EndsWith(".PDF") Then
|
||||
reader = New PdfReader(file)
|
||||
|
||||
addAttachmentToCurrentPDF(reader, pdf)
|
||||
|
||||
pdf.AddDocument(reader)
|
||||
reader.Close()
|
||||
|
||||
End If
|
||||
Next
|
||||
Catch __unusedException1__ As Exception
|
||||
@@ -6549,6 +6555,41 @@ Public Class FormularManagerNEU
|
||||
Return merged
|
||||
End Function
|
||||
|
||||
Public Shared Function addAttachmentToCurrentPDF(reader As PdfReader, copy As PdfCopy)
|
||||
|
||||
Dim catalog As PdfDictionary = reader.Catalog
|
||||
Dim names As PdfDictionary = CType(PdfReader.GetPdfObject(catalog.Get(PdfName.NAMES)), PdfDictionary)
|
||||
|
||||
If names IsNot Nothing Then
|
||||
Dim embeddedFiles As PdfDictionary = CType(PdfReader.GetPdfObject(names.Get(PdfName.EMBEDDEDFILES)), PdfDictionary)
|
||||
If embeddedFiles IsNot Nothing Then
|
||||
Dim filespecs As PdfArray = embeddedFiles.GetAsArray(PdfName.NAMES)
|
||||
|
||||
For i As Integer = 0 To filespecs.Size - 1 Step 2
|
||||
' Get the attachment's file specification
|
||||
Dim fileArray As PdfDictionary = filespecs.GetAsDict(i + 1)
|
||||
Dim file As PdfDictionary = fileArray.GetAsDict(PdfName.EF)
|
||||
|
||||
For Each key As PdfName In file.Keys
|
||||
Dim stream As PRStream = CType(PdfReader.GetPdfObject(file.GetAsIndirectObject(key)), PRStream)
|
||||
Dim fileName As String = fileArray.GetAsString(key).ToString()
|
||||
|
||||
' Create a byte array from the attachment content
|
||||
Dim fileContent As Byte() = PdfReader.GetStreamBytes(stream)
|
||||
|
||||
' Add the attachment to the new PDF
|
||||
Dim fileSpec As PdfFileSpecification = PdfFileSpecification.FileEmbedded(copy, Nothing, fileName, fileContent)
|
||||
copy.AddFileAttachment(fileName, fileSpec)
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
'ALT: Hier kam es zum komischen Problemen bei einem PDF: es wurde eine alte Verison ausgegeben, obwohl die alten texte nicht ersichtlich waren?? --> Infoschreiben Fiskal
|
||||
Public Shared Function MergePdfFiles2ALT(ByVal pdfFiles As List(Of String), ByVal outputPath As String) As Boolean
|
||||
Dim result As Boolean = False
|
||||
|
||||
Reference in New Issue
Block a user