Skip to main content
Inspiring
February 4, 2025
Answered

HTML to PDF: CSS Paged media module

  • February 4, 2025
  • 2 replies
  • 501 views

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

    Correct answer Joel Geraci

    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.

    2 replies

    Participant
    February 4, 2025
    You can go to on one of the websites from the European Union
    Joel Geraci
    Community Expert
    Joel GeraciCommunity ExpertCorrect answer
    Community Expert
    February 4, 2025

    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.

    Inspiring
    February 4, 2025

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

    Joel Geraci
    Community Expert
    Community Expert
    February 4, 2025

    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.