FAQ
FAQ

How can I remove headers, sidebars, cookie banners, or other content from the WordPress PDF?

Use the method that matches where the unwanted content comes from and whether removing it should change the output layout.

Use pdfcrowd-remove or pdfcrowd-hide when you can edit the HTML

If you can edit the page, post, template, or theme HTML, add pdfcrowd-remove or pdfcrowd-hide to the element.

Use pdfcrowd-remove when the element should not take space in the output layout. Use pdfcrowd-hide only when the element should become invisible but the surrounding layout should not move.

<header class="site-header pdfcrowd-remove">...</header>
<div class="ad-slot pdfcrowd-hide">...</div>

Use the Custom CSS option when you cannot edit the HTML

Set the Custom CSS option to hide elements only during conversion:

.site-header,
.sidebar,
.cookie-banner {
  display: none !important;
}

Use the Custom JavaScript option for elements added after page load

Use the Custom JavaScript option when CSS or static HTML classes do not catch the unwanted element because it is inserted after the page loads.

libPdfcrowd.removeBySelector({
  selector: '.cookie-banner, .modal-backdrop',
  recursive: true
});

If the page already loads jQuery, you can also remove elements with jQuery('.selector').remove().

For overlay problems, the Custom JavaScript option can also remove elements above a chosen z-index:

libPdfcrowd.removeZIndexHigherThan({
  zlimit: 1000
});

Use high-z-index cleanup carefully because it can remove normal page elements if your theme or plugins use high z-index values.

Use selected-area conversion when most of the page should be removed

If the output should contain only one selected section, use partial conversion instead of hiding many unrelated page elements. The selected-area approaches are covered in How can I convert only part of a WordPress page to PDF?.