Search code examples
ms-officedocxapache-fopprinter-control-languagedocx4j

Extract XSL-FO from docx4j (or convert straight to PCL)?


Is there a way to extract the XSL-FO from docx4j, or is there a guide (or existing code) to adapting the docx4j pdf output to emit PCL instead of PDF?

The task I am doing is to fill in the fields of a (docx) word document (and optionally remove them or not - i.e. maybe leave them filled in, or replace them with their value), then transform to PCL.


Solution

  • See pdf viaXSLFO, which creates XSLFO as an intermediate step (and optionally saves it).

    You can modify that to give you PCL output. You'll need to change the line:

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, os);
    

    to

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PCL, os);
    

    and add appropriate PCL stuff to the FOP config string, and if you are lucky that'll be it!