1

I am following @JasonPlutext's approach to edit word document on browser from here docx-html-editor. The code here maintains http session and saves design and formatting information in session cookie throughout the entire roadtrip (docx-html-docx) process.

My requirement is I don't want to depend on http session and want to save paragraph design information in local storage.

I tried following ways to achieve it:

  1. serializing instance of WordProcessingMLPackage and retrieve it later, but as this class is very huge bucket of information of various types, I couldn't find any way to serialize it.

  2. I tried to marshal only required user data (Ex. {"DOCX4J_EDITOR:p75": <-instance of PPr->}). I used javax.xml.bind.JAXBContext and javax.xml.bind.Marshaller for it but it gives the following error: There's no ObjectFactory with an @XmlElementDecl for the element {http://schemas.microsoft.com/office/word/2012/wordml}dataBinding.

My question is what is best way to save design information of paragraphs and retrieve them later.

  • Seems like you have a dataBinding element in your PPr, or the object you think is a PPr is actually a dataBinding? This is an error, which is probably why you get that. What is your marshalling code? You can try for example XmlUtils.marshaltoString(ppr) – JasonPlutext May 14 '23 at 03:27
  • Thank you @JasonPlutext Sir. XmlUtils.marshaltoString(ppr) was exactly what I was looking for. – Dhruvin Moradiya May 25 '23 at 16:22

0 Answers0