omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Create docx file using Python-docx?

    Editorial
    4
    4
    5167
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MDB
      MDB last edited by

      I would like to convert an .md or .txt file to a docx, locally. I've been using the docverter workflow, and I'm really happy with it, but it still needs an internet connection, which is sometimes not possible.

      I recently found Python-docx on github (https://github.com/python-openxml/python-docx) which seems to do exactly that.

      I don't have a clue about working in Python. Is this something Editorial can do in a workflow with a python step?

      Is Python-docx even possible to use on an iOS device?

      If not, does anyone have any ideas about how to do the conversion?

      FYI, all I'm really trying to do is send an Editorial file to Word (for iPad) using "open in". I can make Word appear as a sharesheet destination by just giving the file a .docx extension, but of course it won't open in Word.

      Thanks for any advice.

      1 Reply Last reply Reply Quote 1
      • roosterboy197
        roosterboy197 last edited by

        I am pretty sure this isn't possible, since python-docx (and python-xlsx) requires lxml, which is not installed on Pythonista or Editorial and is a C library rather than a native Python module and therefore can't be user-installed. It would require either a) Ole to include lxml as part of the app, or b) someone to rework python-docx and -xlsx to use another XML-parsing module, like say elementtree.

        I would dearly love to be proven wrong, though.

        1 Reply Last reply Reply Quote 1
        • dgbmcc
          dgbmcc last edited by

          The app makeDoc by toketaWare
          https://appsto.re/gb/6bHsK.i

          Can use x-callbacks and will create docx files from markup and text.

          1 Reply Last reply Reply Quote 0
          • Webmaster4o
            Webmaster4o last edited by

            @roosterboy197 I have had some success in the past simply replacing lxml functions with their xml equivalents (only works in some places). I remember getting one module to work by replacing

            import lxml.etree
            

            with

            import xml.etree
            

            sucessfully. I don't know how heavily lxml is used, but in some cases, xml can be used to do the same operations slightly less efficiently.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors