Imports System
Imports System.IO
Imports O2S.Components.PDFRender4NET.WPF

Module Module1

    ''' <summary>
    ''' Main method.
    ''' </summary>
    <STAThread()> _
    Sub Main()
        ' Load the PDF file.
        Dim pdfFile__1 As PDFFile = PDFFile.Open("..\SupportFiles\annotations.pdf")

        ' Get the image stream
        Dim imageStream As Stream = pdfFile__1.GetPageImage(0, 39, 39, OutputImageType.BMP)

        ' Save the stream to disk
        Dim fs As FileStream = File.OpenWrite(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\pageimage.bmp")
        Dim imageBytes As Byte() = DirectCast(imageStream, MemoryStream).ToArray()
        fs.Write(imageBytes, 0, imageBytes.Length)
        fs.Close()
    End Sub

End Module
