Converting doc / docx files to pdf in PythonHow can I represent an 'Enum' in Python?Convert bytes to a string?Best way to convert string to bytes in Python 3?Way to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Converting docx to pdf via JODConverter and LibreOffice causes errorWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Converting email into PDF using pythonLooping over the .doc files to convert them to .pdf (Python)Convert Non-Searchable Pdf to Searchable Pdf in Windows Python

whey we use polarized capacitor?

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

New order #4: World

Why is this code 6.5x slower with optimizations enabled?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

Is it possible to make sharp wind that can cut stuff from afar?

How to report a triplet of septets in NMR tabulation?

"which" command doesn't work / path of Safari?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Compute hash value according to multiplication method

How is this relation reflexive?

How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators?

Prevent a directory in /tmp from being deleted

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

What do you call a Matrix-like slowdown and camera movement effect?

Why is the design of haulage companies so “special”?

Why is an old chain unsafe?

How to re-create Edward Weson's Pepper No. 30?

Possibly bubble sort algorithm

declaring a variable twice in IIFE

If Manufacturer spice model and Datasheet give different values which should I use?

Pronouncing Dictionary.com's W.O.D "vade mecum" in English

What exactly is the parasitic white layer that forms after iron parts are treated with ammonia?



Converting doc / docx files to pdf in Python


How can I represent an 'Enum' in Python?Convert bytes to a string?Best way to convert string to bytes in Python 3?Way to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”Converting docx to pdf via JODConverter and LibreOffice causes errorWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Converting email into PDF using pythonLooping over the .doc files to convert them to .pdf (Python)Convert Non-Searchable Pdf to Searchable Pdf in Windows Python






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















Is there a good library which can convert doc file to pdf? There are some paid options available like cloudconvert, convertApi etc but I am looking for a free option. My python app is hosted on EC2 machine.
I also looked at python-docx library which can allow me to read the contents of the doc file, but writing the contents to pdf file will break the styling I suppose.










share|improve this question




























    1















    Is there a good library which can convert doc file to pdf? There are some paid options available like cloudconvert, convertApi etc but I am looking for a free option. My python app is hosted on EC2 machine.
    I also looked at python-docx library which can allow me to read the contents of the doc file, but writing the contents to pdf file will break the styling I suppose.










    share|improve this question
























      1












      1








      1








      Is there a good library which can convert doc file to pdf? There are some paid options available like cloudconvert, convertApi etc but I am looking for a free option. My python app is hosted on EC2 machine.
      I also looked at python-docx library which can allow me to read the contents of the doc file, but writing the contents to pdf file will break the styling I suppose.










      share|improve this question














      Is there a good library which can convert doc file to pdf? There are some paid options available like cloudconvert, convertApi etc but I am looking for a free option. My python app is hosted on EC2 machine.
      I also looked at python-docx library which can allow me to read the contents of the doc file, but writing the contents to pdf file will break the styling I suppose.







      python-3.x pdf-conversion






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 5 at 12:05









      VivekVivek

      1,0771331




      1,0771331






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Here is a VBA solution for you (I don't know how to do this using Python).



          If you need to convert multiple Word files to other formats, like TXT, RTF, HTML or PDF, run the script below.



          Option Explicit On

          Sub ChangeDocsToTxtOrRTFOrHTML()
          'with export to PDF in Word 2007
          Dim fs As Object
          Dim oFolder As Object
          Dim tFolder As Object
          Dim oFile As Object
          Dim strDocName As String
          Dim intPos As Integer
          Dim locFolder As String
          Dim fileType As String
          On Error Resume Next

          locFolder = InputBox("Enter the folder path to DOCs", "File Conversion", "C:Usersyour_path_here")
          Select Case Application.Version
          Case Is < 12
          Do
          fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML", "File Conversion", "TXT"))
          Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML")
          Case Is >= 12
          Do
          fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML or PDF(2007+ only)", "File Conversion", "TXT"))
          Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML" Or fileType = "PDF")
          End Select

          Application.ScreenUpdating = False
          Set fs = CreateObject("Scripting.FileSystemObject")
          Set oFolder = fs.GetFolder(locFolder)
          Set tFolder = fs.CreateFolder(locFolder & "Converted")
          Set tFolder = fs.GetFolder(locFolder & "Converted")

          For Each oFile In oFolder.Files
          Dim d As Document
          Set d = Application.Documents.Open(oFile.Path)
          strDocName = ActiveDocument.Name
          intPos = InStrRev(strDocName, ".")
          strDocName = Left(strDocName, intPos - 1)
          ChangeFileOpenDirectory tFolder
          Select Case fileType
          Case Is = "TXT"
          strDocName = strDocName & ".txt"
          ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
          Case Is = "RTF"
          strDocName = strDocName & ".rtf"
          ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatRTF
          Case Is = "HTML"
          strDocName = strDocName & ".html"
          ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatFilteredHTML
          Case Is = "PDF"
          strDocName = strDocName & ".pdf"
          ActiveDocument.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF
          End Select
          d.Close
          ChangeFileOpenDirectory oFolder
          Next oFile
          Application.ScreenUpdating = True

          End Sub





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55002479%2fconverting-doc-docx-files-to-pdf-in-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Here is a VBA solution for you (I don't know how to do this using Python).



            If you need to convert multiple Word files to other formats, like TXT, RTF, HTML or PDF, run the script below.



            Option Explicit On

            Sub ChangeDocsToTxtOrRTFOrHTML()
            'with export to PDF in Word 2007
            Dim fs As Object
            Dim oFolder As Object
            Dim tFolder As Object
            Dim oFile As Object
            Dim strDocName As String
            Dim intPos As Integer
            Dim locFolder As String
            Dim fileType As String
            On Error Resume Next

            locFolder = InputBox("Enter the folder path to DOCs", "File Conversion", "C:Usersyour_path_here")
            Select Case Application.Version
            Case Is < 12
            Do
            fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML", "File Conversion", "TXT"))
            Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML")
            Case Is >= 12
            Do
            fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML or PDF(2007+ only)", "File Conversion", "TXT"))
            Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML" Or fileType = "PDF")
            End Select

            Application.ScreenUpdating = False
            Set fs = CreateObject("Scripting.FileSystemObject")
            Set oFolder = fs.GetFolder(locFolder)
            Set tFolder = fs.CreateFolder(locFolder & "Converted")
            Set tFolder = fs.GetFolder(locFolder & "Converted")

            For Each oFile In oFolder.Files
            Dim d As Document
            Set d = Application.Documents.Open(oFile.Path)
            strDocName = ActiveDocument.Name
            intPos = InStrRev(strDocName, ".")
            strDocName = Left(strDocName, intPos - 1)
            ChangeFileOpenDirectory tFolder
            Select Case fileType
            Case Is = "TXT"
            strDocName = strDocName & ".txt"
            ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
            Case Is = "RTF"
            strDocName = strDocName & ".rtf"
            ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatRTF
            Case Is = "HTML"
            strDocName = strDocName & ".html"
            ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatFilteredHTML
            Case Is = "PDF"
            strDocName = strDocName & ".pdf"
            ActiveDocument.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF
            End Select
            d.Close
            ChangeFileOpenDirectory oFolder
            Next oFile
            Application.ScreenUpdating = True

            End Sub





            share|improve this answer



























              0














              Here is a VBA solution for you (I don't know how to do this using Python).



              If you need to convert multiple Word files to other formats, like TXT, RTF, HTML or PDF, run the script below.



              Option Explicit On

              Sub ChangeDocsToTxtOrRTFOrHTML()
              'with export to PDF in Word 2007
              Dim fs As Object
              Dim oFolder As Object
              Dim tFolder As Object
              Dim oFile As Object
              Dim strDocName As String
              Dim intPos As Integer
              Dim locFolder As String
              Dim fileType As String
              On Error Resume Next

              locFolder = InputBox("Enter the folder path to DOCs", "File Conversion", "C:Usersyour_path_here")
              Select Case Application.Version
              Case Is < 12
              Do
              fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML", "File Conversion", "TXT"))
              Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML")
              Case Is >= 12
              Do
              fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML or PDF(2007+ only)", "File Conversion", "TXT"))
              Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML" Or fileType = "PDF")
              End Select

              Application.ScreenUpdating = False
              Set fs = CreateObject("Scripting.FileSystemObject")
              Set oFolder = fs.GetFolder(locFolder)
              Set tFolder = fs.CreateFolder(locFolder & "Converted")
              Set tFolder = fs.GetFolder(locFolder & "Converted")

              For Each oFile In oFolder.Files
              Dim d As Document
              Set d = Application.Documents.Open(oFile.Path)
              strDocName = ActiveDocument.Name
              intPos = InStrRev(strDocName, ".")
              strDocName = Left(strDocName, intPos - 1)
              ChangeFileOpenDirectory tFolder
              Select Case fileType
              Case Is = "TXT"
              strDocName = strDocName & ".txt"
              ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
              Case Is = "RTF"
              strDocName = strDocName & ".rtf"
              ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatRTF
              Case Is = "HTML"
              strDocName = strDocName & ".html"
              ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatFilteredHTML
              Case Is = "PDF"
              strDocName = strDocName & ".pdf"
              ActiveDocument.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF
              End Select
              d.Close
              ChangeFileOpenDirectory oFolder
              Next oFile
              Application.ScreenUpdating = True

              End Sub





              share|improve this answer

























                0












                0








                0







                Here is a VBA solution for you (I don't know how to do this using Python).



                If you need to convert multiple Word files to other formats, like TXT, RTF, HTML or PDF, run the script below.



                Option Explicit On

                Sub ChangeDocsToTxtOrRTFOrHTML()
                'with export to PDF in Word 2007
                Dim fs As Object
                Dim oFolder As Object
                Dim tFolder As Object
                Dim oFile As Object
                Dim strDocName As String
                Dim intPos As Integer
                Dim locFolder As String
                Dim fileType As String
                On Error Resume Next

                locFolder = InputBox("Enter the folder path to DOCs", "File Conversion", "C:Usersyour_path_here")
                Select Case Application.Version
                Case Is < 12
                Do
                fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML", "File Conversion", "TXT"))
                Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML")
                Case Is >= 12
                Do
                fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML or PDF(2007+ only)", "File Conversion", "TXT"))
                Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML" Or fileType = "PDF")
                End Select

                Application.ScreenUpdating = False
                Set fs = CreateObject("Scripting.FileSystemObject")
                Set oFolder = fs.GetFolder(locFolder)
                Set tFolder = fs.CreateFolder(locFolder & "Converted")
                Set tFolder = fs.GetFolder(locFolder & "Converted")

                For Each oFile In oFolder.Files
                Dim d As Document
                Set d = Application.Documents.Open(oFile.Path)
                strDocName = ActiveDocument.Name
                intPos = InStrRev(strDocName, ".")
                strDocName = Left(strDocName, intPos - 1)
                ChangeFileOpenDirectory tFolder
                Select Case fileType
                Case Is = "TXT"
                strDocName = strDocName & ".txt"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
                Case Is = "RTF"
                strDocName = strDocName & ".rtf"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatRTF
                Case Is = "HTML"
                strDocName = strDocName & ".html"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatFilteredHTML
                Case Is = "PDF"
                strDocName = strDocName & ".pdf"
                ActiveDocument.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF
                End Select
                d.Close
                ChangeFileOpenDirectory oFolder
                Next oFile
                Application.ScreenUpdating = True

                End Sub





                share|improve this answer













                Here is a VBA solution for you (I don't know how to do this using Python).



                If you need to convert multiple Word files to other formats, like TXT, RTF, HTML or PDF, run the script below.



                Option Explicit On

                Sub ChangeDocsToTxtOrRTFOrHTML()
                'with export to PDF in Word 2007
                Dim fs As Object
                Dim oFolder As Object
                Dim tFolder As Object
                Dim oFile As Object
                Dim strDocName As String
                Dim intPos As Integer
                Dim locFolder As String
                Dim fileType As String
                On Error Resume Next

                locFolder = InputBox("Enter the folder path to DOCs", "File Conversion", "C:Usersyour_path_here")
                Select Case Application.Version
                Case Is < 12
                Do
                fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML", "File Conversion", "TXT"))
                Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML")
                Case Is >= 12
                Do
                fileType = UCase(InputBox("Change DOC to TXT, RTF, HTML or PDF(2007+ only)", "File Conversion", "TXT"))
                Loop Until (fileType = "TXT" Or fileType = "RTF" Or fileType = "HTML" Or fileType = "PDF")
                End Select

                Application.ScreenUpdating = False
                Set fs = CreateObject("Scripting.FileSystemObject")
                Set oFolder = fs.GetFolder(locFolder)
                Set tFolder = fs.CreateFolder(locFolder & "Converted")
                Set tFolder = fs.GetFolder(locFolder & "Converted")

                For Each oFile In oFolder.Files
                Dim d As Document
                Set d = Application.Documents.Open(oFile.Path)
                strDocName = ActiveDocument.Name
                intPos = InStrRev(strDocName, ".")
                strDocName = Left(strDocName, intPos - 1)
                ChangeFileOpenDirectory tFolder
                Select Case fileType
                Case Is = "TXT"
                strDocName = strDocName & ".txt"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatText
                Case Is = "RTF"
                strDocName = strDocName & ".rtf"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatRTF
                Case Is = "HTML"
                strDocName = strDocName & ".html"
                ActiveDocument.SaveAs FileName:=strDocName, FileFormat:=wdFormatFilteredHTML
                Case Is = "PDF"
                strDocName = strDocName & ".pdf"
                ActiveDocument.ExportAsFixedFormat OutputFileName:=strDocName, ExportFormat:=wdExportFormatPDF
                End Select
                d.Close
                ChangeFileOpenDirectory oFolder
                Next oFile
                Application.ScreenUpdating = True

                End Sub






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 9 at 3:48









                ryguy72ryguy72

                4,6211824




                4,6211824





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55002479%2fconverting-doc-docx-files-to-pdf-in-python%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme