Page 1 of 1

ImportHTML support for CSS3 running header/footer

PostPosted: Mon Nov 09, 2015 3:00 pm
by stevej

Is there any support for the CSS3 running header styles? Example:

Code: Select all
    <style type="text/css">
      @page {
        @top-left { content: element(leftHeader) };
      div.leftHeader { position: running(leftHeader); }

    <div class="leftHeader">
      <p>Header Text</p>
      <p>Page content here....</p>


Flying saucer supports this - the header element is repeated at the top of every page when exported to PDF, but not with DOCX.


Re: ImportHTML support for CSS3 running header/footer

PostPosted: Wed Nov 11, 2015 8:12 am
by jason
iirc, no.

But if the info is available from FlyingSaucer, then it could be converted to a HeaderPart (or FooterPart) and referenced in a sectPr element.

Re: ImportHTML support for CSS3 running header/footer

PostPosted: Tue May 09, 2017 2:30 am
by csekol

I am facing the same issue.
Do you mean rendering the html with flyingsaucer using ITextRenderer and then get the appropriate header from it?
Something like this:
Code: Select all
            ITextRenderer renderer  = new ITextRenderer();
            renderer.setDocument(new File("header_runningelements.html"));

            Layer layer = renderer.getRootBox().getLayer();
            PageBox firstPage = (PageBox) layer.getPages().get(0);
            BlockBox leftHeader = layer.getRunningBlock("leftHeader", firstPage, PageElementPosition.FIRST);

now I have a left header box, I can reuse the code in XHTMLImporter.traverse() to render the content and put it in the header/footer part.

Could you please confirm if this is a good direction? Or is there a better way?