I have this code, and I just want to export all pages or a specific page from the loaded PDF in the RadPdfViewer, without saving the file to the computer.
The function RadPdfViewer.ExportPage returns a Bitmap, but when I assign the result of this function to a new variable of type Bitmap, an error occurs.
'1º Option - Work
For i As Integer = 1 To RadPdfViewer1.Document.Pages.Count
Dim guid As Guid = Guid.NewGuid
RadPdfViewer1.ExportPage(i, "C:\temp\" & guid.ToString() & ".pdf", 1, True, ImageFormat.Png)
Dim bitmap As Bitmap = New Bitmap("C:\temp\" & guid.ToString() & ".pdf")
Dim reader As BarcodeReader = New BarcodeReader With {
.AutoRotate = True,
.TryInverted = True
}
Dim result As Result = reader.Decode(bitmap)
If result Is Nothing Then Continue For
Dim decoded As String = result.ToString().Trim()
If decoded Is Nothing Then Continue For
If decoded <> TextBox1.Text Then TextBox1.Text = TextBox1.Text & vbNewLine & vbNewLine & decoded
bitmap.Dispose()
My.Computer.FileSystem.DeleteFile("C:\temp\" & guid.ToString() & ".pdf")
Next
'2 Option - Dont Work
Dim bitmap As Bitmap = RadPdfViewer1.ExportPage(1, 1, False, ImageFormat.Png)
'3º Option - Dont Work
For Each bitmap As Bitmap In RadPdfViewer1.ExportPages(1, False, ImageFormat.Bmp)
Dim reader As BarcodeReader = New BarcodeReader With {
.AutoRotate = True,
.TryInverted = True
}
Dim result As Result = reader.Decode(bitmap)
If result Is Nothing Then Continue For
Dim decoded As String = result.ToString().Trim()
If decoded Is Nothing Then Continue For
If decoded <> TextBox1.Text Then TextBox1.Text = TextBox1.Text & vbNewLine & vbNewLine & decoded
Next