docx4j-ImportXHTML icon indicating copy to clipboard operation
docx4j-ImportXHTML copied to clipboard

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

Open achimmihca opened this issue 4 years ago • 3 comments

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 avatar Jan 06 '21 11:01 achimmihca

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

achimmihca avatar Jan 06 '21 11:01 achimmihca

@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 :-)

plutext avatar Jan 11 '21 02:01 plutext

Hello! Is this still unsupported?

LucasJC avatar May 10 '22 18:05 LucasJC