11
submitted 9 months ago* (last edited 9 months ago) by Red1C3@lemmy.world to c/programming@programming.dev

Long story short, I want to build a system that reorders some components in a document file (be it a docx or odt, I don't have a hard constraint atm).

So my problem input should be a document file, and I need to be able to approximate the number of pages consumed by this document file, I also need to be able to get the height of individual components (like a single paragraph or a table) to have the data I need to rearrange so I can make the document have less pages.

I don't have a hard constraint on the programming language of the tool either (Python preferred), I prefer not embedding LibreOffice into my system.

Also I'm willing to hear other solutions (maybe my input is not the optimal thing I can use for this problem).

Thanks in advance!

you are viewing a single comment's thread
view the rest of the comments
[-] unmagical@lemmy.ml 7 points 9 months ago

A docx is just a renamed zip archive with the XML data. You should be able to unzip it and use a parser to access that info directly. There are likely tools to do this for any relevant language. You can also find the official spec online with some more info.

Unfortunately, I can't get into much more detail than that as my company actively develops similar tools and I've worked on their document renderers not too long ago.

No clue on the odt stuff. I worked on the MS fidelity part.

this post was submitted on 13 Jan 2024
11 points (100.0% liked)

Programming

17314 readers
244 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS