Skip to main content
Inspiring
Feb 4, 2025 11:14 AM UTC
Answered

HTML to PDF: CSS Paged media module

Does anyone know which CSS paged media module properties are supported by HTML to PDF API? Is there documentation for this somewhere?

 

Margins seems to work, boxes not:

@4025150 {

	/* works */
	margin-top: 15mm;
	margin-bottom: 15mm;
	margin-left: 15mm;
	margin-right: 15mm;

	/* no result */
	@bottom-center {
		content: "– " counter(page) " –";
	}
}

 

Or better work with pagedjs.

 

Thanks
Roland

    Joel Geraci
    Joel GeraciCorrect answer
    Community Expert
    Feb 4, 2025 4:13 PM UTC

    At the time of this writing the API supports Level 2.

    The API also works with pagedjs for some features. Unfortunately, pagedjs sometimes creates invalid HTML that the browsers just kind of ignore but our API can't. I've not been able to work around these HTML errors.

    5 replies

    Participant
    Feb 4, 2025 8:36 PM UTC
    You can go to on one of the websites from the European Union
    Translate
    Joel Geraci
    Community Expert
    Joel GeraciCommunity ExpertCorrect answer
    Community Expert
    Feb 4, 2025 4:13 PM UTC

    At the time of this writing the API supports Level 2.

    The API also works with pagedjs for some features. Unfortunately, pagedjs sometimes creates invalid HTML that the browsers just kind of ignore but our API can't. I've not been able to work around these HTML errors.

    Translate
    Inspiring
    Feb 4, 2025 5:15 PM UTC

    Thanks for the answer and your experience, good to know.

    Translate
    Joel Geraci
    Community Expert
    Community Expert
    Feb 4, 2025 10:44 PM UTC

    To test what works, use pagedjs and view the generated page. Then save the HTML and open that in an editor. You'll see the errors immediately. Most have to do with calculated values. I even tried editing the source of pagedjs and couldn't get it to work.

    Translate