Code Monkey home page Code Monkey logo

Comments (6)

freb avatar freb commented on August 29, 2024

Hey Todd. I just made the repo public so you can take a look:

https://github.com/aerissecure/docx2pdf

As you'll see from the README, the call is extremely simple and requires no authentication.

Another repo I just made public is for converting markdown into docx using blackfriday v2. It could probably use a few cleanups but most everything is supported:

https://github.com/aerissecure/md2docx

I'd like to eventually support fenced code blocks with language identification and a custom Chroma formatter for docx output: https://github.com/alecthomas/chroma

Did you have any thoughts on my suggestion for table of contents generation? As I mentioned, I realize that is a total long shot, but just wondering if its a hard no or something that you think might be feasible at some point.

Thanks!

from unioffice.

tbaliance avatar tbaliance commented on August 29, 2024

@freb I think you're the first person on the internet to discover it, and definitely the first person to document it!

I looked into TOC generation at one point, you can insert the content easily enough but the thing I could never figure out was page number calculations. You'd have to implement basically the Word layout engine in order to figure out what the page numbers should be.

from unioffice.

freb avatar freb commented on August 29, 2024

That makes total sense about the TOC generation. Even Latex has to make multiple passes for those calculations and its actually doing the rendering.

If the online version of word ever supports TOC generation, there will probably be some way to use it programmatically.

Note that I tried to convert other file formats (xlsx) with the same Microsoft endpoint and it doesn't appear to be supported. OneDrive appears to have an API that can convert between almost anything, but it would never be as simple as the docx->pdf converstion: https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get_content_format

from unioffice.

freb avatar freb commented on August 29, 2024

Sorry to keep talking about the TOC in this issue. If you think it would be helpful to anyone else, we could start another issue with options and workarounds.

I just figured out it would be possible to host your own conversion server using a real Word installation on Windows using COM. github.com/go-ole/go-ole works well for opening and re-saving. Running Windows is far from ideal, but at least there is an option that works and is feasible.

I also found this c# library that generates TOC, but if I understand it correcty they have basically replicated all of the Word rending functionality in their own code for the functions they support, which is nuts. https://help.syncfusion.com/file-formats/docio/overview

from unioffice.

tbaliance avatar tbaliance commented on August 29, 2024

@freb I'm not too sure about using the undocumented MS url for conversion, but I think your OLE idea was great. I'm adding two examples, one that does a PDF export and another that generates the TOC like you mentioned.

from unioffice.

freb avatar freb commented on August 29, 2024

I started liking that idea more after I mentioned it as well. I'm glad to see the examples!

from unioffice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.