danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!

Home Page:https://danfickle.github.io/pdf-templates/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for element grouping

AndreasJacobsen opened this issue · comments

I am generating a very long pdf (100+ pages) and I want to group elements in this pdf using standard PDF grouping tags.

These are Part, Art, Sect, Div

See pdfa.org for more information.

I tried searching for any documentation on how to use standard PDF tags but found none, so I tried to guess the tags. I wrote the following HTML

<html lang="EN-US">
<style>
                body {
    font-family: 'TestFont';
                }
    </style>
<body>
<h1>Testdokument</h1>
<section>
 <p>Section</p>
</section>
<Section>
 <p>Section</p>
</Section>
<sect>
 <p>sect</p>
</sect>
<Sect>
 <p>Sect</p>
</Sect>
<Art>
 <p>Art</p>
</Art>
<art>
 <p>art</p>
</art>
<part>
 <p>part</p>
</part>
<Part>
 <p>Part</p>
</Part>
</body>
</html>

This HTML produces the following tag tree, no section, part or art tags are present.
tag tree showing none of the pdf tags used

Attached bellow is a screenshot of a PDF that contains the use of the Sect-elemt, this is what I want.
Screenshot of tag tree with section tags

Are PDF tag grouping not supported?
Grouping can drasticly increase ease of use, especially in long documents, for a wide range of users of assistive technologies.

I've set my conformance level to PDFA_3_A
builder.usePdfAConformance(PdfRendererBuilder.PdfAConformance.PDFA_3_A);

Hi @AndreasJacobsen,

I've just added support for art, part, sect, section (alias for sect), caption and blockquote tags in 7ab966e. You can use art currently with <article> and you may be able to use sect with position: relative CSS as it uses sect for out-of-flow content.

I'll make a pull request for the wiki once I have tested this, thanks danfickle!

My Java skills are sadly pretty much non-existent so I'll wait till this is merged to main and I can update my maven packages to test and document.

Any idea when this will be available on Maven @danfickle? I don't want you to rush it, I just need to do some planning :)