How to convert multiple DOCX files into PDF using VB.NET


Article from our customer

I’ve a Web-application which has to convert various DOCX files in PDF! I’ve googled a lot and found that many .NET components support only RTF and DOC formats, but not DOCX.

As a result, I’ve chose UseOffice .Net

This is my example of how you can convert DOCX files to PDF at server side:


            Dim u As New SautinSoft.UseOffice()
       'Path to any local file
        Dim inputFilePath As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "С:\Server\DOC.docx"))
        'Path to output resulted file
        Dim outputFilePath As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "С:\Server\Result.pdf"))
        'Prepare UseOffice .Net, loads MS Word in memory
        Dim ret As Integer = u.InitWord()
        'Return values:
        '0 - Loading successfully
        '1 - Can't load MS Word® library in memory
        If ret = 1 Then
            Return
        End If
        'Converting
        ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.DOCX_to_PDF)
        'Release MS Word from memory
        u.CloseWord()
                    

If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below:



Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.