plutext / docx4j-ImportXHTML

Converts XHTML to OpenXML WordML (docx) using docx4j
136 stars 125 forks source link

Use page size, margins, header and footer texts from CSS @page #65

Open achimmihca opened 3 years ago

achimmihca commented 3 years ago

Would be nice if overall page features could be expressed using CSS.

Example:

@page {
    size: A4; /*could also be other values, e.g., 270mm, 10cm*/
    margin: 1cm; /* could also be 4 values for top,bottom,left,right as usual in CSS*/

    @top-left {
      content: counter(page);   
    }

    @bottom-center {
      content: 'You are on ' counter(page) ' of ' counter(pages);   
    }

    @bottom-right {
       content: 'Bottom right text';    
    }
}

For an overview of available boxes in css (such as bottom-right) see here

To implement this, I would provide a new factory method that creates the WordprocessingMLPackage object from either CSS or XHTML (its style-Tag).


In general, it would be nice if a document such as this example from OpenHtmlToPdf would produce a similar docx file when consumed by docx4j-ImportXHTML.

achimmihca commented 3 years ago

As starting point, I added an example of how to add margins and footer using docx4j in the wiki.

plutext commented 3 years ago

@achimmihca just a heads up that we are working to migrate from FlyingSaucer to openhtmltopdf; see https://github.com/plutext/docx4j-ImportXHTML/commits/openhtmltopdf so our attention is focused on that branch. If you are doing further testing/analysis of docx4j-ImportXHTML, it may be better to wait a little while until the dust settles, then focus your efforts on that branch. And thanks for populating the wiki content :-)

LucasJC commented 2 years ago

Hello! Is this still unsupported?