We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert Word to Image VB.NET

Convert Page Range of Word DOCX to JPEG Image Files using VB.NET

I am getting the next error I have Aspose.Words for .NET 21.8

‘setPageSet’ is not a member of ‘Aspose.Words.Saving.ImageSaveOptions’.

send you example of code and file

 ' --- get DOCX
      '---=== 1.1 open document from disk ===--
        Dim docWord As New Aspose.Words.Document(fileFolder + fileName)
        docWord.RemoveMacros()
        Dim options As ImageSaveOptions = New ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg)
        options.JpegQuality = 100
        options.PageCount = 1
    
        For i As Integer = 0 To docWord.PageCount - 1
            options.PageIndex = i
            docWord.Save(imageStream, options )
        Next

        '---=== response binary for debuging ===--
        '================================================================================================================
        Response.Clear()
        Response.ClearContent()
        Response.ClearHeaders()
        Response.AddHeader("Content-Description", "File Transfer")
        Response.ContentType = "application/octet-stream" 
        Response.AddHeader("content-disposition", "attachment; filename=test.jpeg")
        Response.AddHeader("Content-Transfer-Encoding", "binary")
        imageStream.WriteTo(Response.OutputStream)

file2.docx (20.9 KB)

@eranlipi,

Please check the following code example to convert word to image vb.net using Aspose.Words for .NET API. The VB.NET code basically converts a Word DOCX document to JPEG Image files:

Imports Aspose.Words
Imports Aspose.Words.Saving

Module Module1

    Sub Main()

        Dim lic As Aspose.Words.License = New Aspose.Words.License()
        lic.SetLicense("C:\\Temp\\license.lic")

        Dim doc As Document = New Document("C:\\Temp\\file2.docx")

        Dim imageSaveOptions As ImageSaveOptions = New ImageSaveOptions(SaveFormat.Jpeg)
        Dim PageRange As PageRange = New PageRange(0, doc.PageCount - 1)
        imageSaveOptions.PageSet = New PageSet(PageRange)
        imageSaveOptions.PageSavingCallback = New HandlePageSavingCallback()

        doc.Save("C:\\Temp\\vb-21.8.jpg", imageSaveOptions)

    End Sub


    Private Class HandlePageSavingCallback
        Implements IPageSavingCallback

        Private Sub IPageSavingCallback_PageSaving(args As PageSavingArgs) Implements IPageSavingCallback.PageSaving
            args.PageFileName = String.Format("C:\\Temp\\Page_{0}.jpg", args.PageIndex)
        End Sub

    End Class

End Module