WIP: PDF Attachment Extractor
This commit is contained in:
parent
ea4673f161
commit
b995304ee3
12
GUIs.Test.DocumentViewerTest/Form1.Designer.vb
generated
12
GUIs.Test.DocumentViewerTest/Form1.Designer.vb
generated
@ -27,6 +27,7 @@ Partial Class Form1
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.Button2 = New System.Windows.Forms.Button()
|
||||
Me.Button3 = New System.Windows.Forms.Button()
|
||||
Me.Button4 = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'TextBox1
|
||||
@ -67,11 +68,21 @@ Partial Class Form1
|
||||
Me.Button3.Text = "Load Form4"
|
||||
Me.Button3.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Button4
|
||||
'
|
||||
Me.Button4.Location = New System.Drawing.Point(12, 96)
|
||||
Me.Button4.Name = "Button4"
|
||||
Me.Button4.Size = New System.Drawing.Size(637, 23)
|
||||
Me.Button4.TabIndex = 3
|
||||
Me.Button4.Text = "Extract Files from PDF"
|
||||
Me.Button4.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(800, 450)
|
||||
Me.Controls.Add(Me.Button4)
|
||||
Me.Controls.Add(Me.Button3)
|
||||
Me.Controls.Add(Me.Button2)
|
||||
Me.Controls.Add(Me.Button1)
|
||||
@ -87,4 +98,5 @@ Partial Class Form1
|
||||
Friend WithEvents Button1 As Button
|
||||
Friend WithEvents Button2 As Button
|
||||
Friend WithEvents Button3 As Button
|
||||
Friend WithEvents Button4 As Button
|
||||
End Class
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class Form1
|
||||
Private oSubform As Form3
|
||||
@ -35,4 +36,44 @@ Public Class Form1
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
|
||||
Using oGdPicturePDF As GdPicturePDF = New GdPicturePDF()
|
||||
If oGdPicturePDF.LoadFromFile(TextBox1.Text, False) = GdPictureStatus.OK Then
|
||||
Dim embeddedFileCount As Integer = oGdPicturePDF.GetEmbeddedFileCount()
|
||||
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
|
||||
If embeddedFileCount > 0 Then
|
||||
Dim FileName As String = oGdPicturePDF.GetEmbeddedFileName(0)
|
||||
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
|
||||
Dim FileSize As Integer = oGdPicturePDF.GetEmbeddedFileSize(0)
|
||||
If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
|
||||
Dim FileData As Byte() = New Byte(FileSize) {}
|
||||
Dim status As GdPictureStatus = oGdPicturePDF.ExtractEmbeddedFile(0, FileData)
|
||||
If status = GdPictureStatus.OK Then
|
||||
MessageBox.Show("The content of the first embedded file has been extracted successfully.", "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
Dim oFileStream As System.IO.FileStream = Nothing
|
||||
oFileStream = New System.IO.FileStream(FileName + "_content.dat", System.IO.FileMode.Create)
|
||||
oFileStream.Write(FileData, 0, FileData.Length)
|
||||
oFileStream.Close()
|
||||
MessageBox.Show("The content of the embedded file has been saved successfully.", "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
Else
|
||||
MessageBox.Show("The embedded file has failed to extract. Status: " + status.ToString(), "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("An error occurred getting the file size. Status: " + oGdPicturePDF.GetStat().ToString(), "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("An error occurred getting the file name. Status: " + oGdPicturePDF.GetStat().ToString(), "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("This PDF file does not contain embedded files.", "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("An error occurred getting the number of embedded files. Status: " + oGdPicturePDF.GetStat().ToString(), "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("The file can't be loaded.", "Example: Emdedded files (Attachments)", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
End Using
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
9
Modules.Jobs/EDMI/ZUGFeRD/PDFAttachments.vb
Normal file
9
Modules.Jobs/EDMI/ZUGFeRD/PDFAttachments.vb
Normal file
@ -0,0 +1,9 @@
|
||||
Public Class PDFAttachments
|
||||
Public Sub New(GdPictureKey As String)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Function Extract(FileName As String)
|
||||
Using oGDPicturePDF As New GDPicturePDF
|
||||
End Function
|
||||
End Class
|
||||
@ -88,6 +88,7 @@
|
||||
<Compile Include="EDMI\GraphQL\GraphQLJob.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\EmailData.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\ImportZUGFeRDFiles.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\PDFAttachments.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\PropertyValues.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\WorkerArgs.vb" />
|
||||
<Compile Include="EDMI\ZUGFeRD\XmlItemProperty.vb" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user