I'm currently using the docx package in my react project to dynamically create DOCX files.
The content depends on what some complex user selection in the UI.
I also need to show the user how much space is left in a any given page in the generated file, so he can decide if/what to insert at the end of that page (the layout of the document is important, so it can't just flow over to the next page if it's too big).
Is there a way to measure how much space is left in a given page in the generated file (e.g. in inches/cm)?
Obviously it would have been great to have this information before the initial generation of the file, but as I understood from the package creators it's not possible using that package.
So as a last resort maybe there is a different package that can take a docx file as input and give this information via the package API?
CodePudding user response:
Is there a way to measure how much space is left in a given page in the generated file (e.g. in inches/cm)?
No, a DOCX file does not contain information needed to determine how much space remains on any given page at any given point on the page because such information is a function of line break and pagination algorithms which are implementation-dependent — not a part of the DOCX (OOXML Word Processing) standard.
One might attempt to replicate the necessary algorithms needed to perform such calculations, but the complexity (and likelihood of variation from the results of MS Word itself) would be quite high.