DocumentViewer: Add Testforms
This commit is contained in:
76
Controls.DocumentViewer/frmTest.vb
Normal file
76
Controls.DocumentViewer/frmTest.vb
Normal file
@@ -0,0 +1,76 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class frmTest
|
||||
Private LogConfig As LogConfig
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath,
|
||||
Application.StartupPath,
|
||||
Nothing,
|
||||
My.Application.Info.CompanyName,
|
||||
My.Application.Info.ProductName)
|
||||
|
||||
LogConfig = oLogConfig
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Dim oResult = OpenFileDialog1.ShowDialog()
|
||||
|
||||
If oResult = DialogResult.OK Then
|
||||
TextBox1.Text = OpenFileDialog1.FileName
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
||||
Try
|
||||
Dim oKey = "0467389434974657969312056"
|
||||
Dim oSubform As New frmTest_SubForm(LogConfig, oKey)
|
||||
|
||||
oSubform.FilePath = TextBox1.Text
|
||||
oSubform.Show()
|
||||
Catch ex As Exception
|
||||
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
|
||||
Reference in New Issue
Block a user