Issues With Print PDF Exporting
This section covers issues (and, where know, their solutions) that are known to occur when exporting regular Pressbooks text to Print PDF format. For issues related to LaTeX not displaying properly in PDF exports, please see Math Typesetting: LaTeX.
Mysterious Spaces in PDF
<0xa0>
). This character is not visible in the Pressbooks Visual or Text editors, but can be seen by copy/pasting the HTML text into a text editor such as Notepad++ or Sublime Text (you may have to ensure the editor is set to display all characters).Issues With Tables (Sizing and Word Wrap)
- Tables with fixed widths (“width: 987px” rather than “width: 100%”) sometimes overflow to the right of the page. These need to be adjusted in the Pressbooks Text Editor, with the overall table width as well as the column widths made dynamic (a percentage value) or the width property left out altogether.
- If dynamically sizing the table and reducing the font size doesn’t work, you can force the Prince PDF converter to shrink the table to fit the page — however, this also places the table on a dedicated page separated from the rest of the content, so this method should only be used as a last resort. In your PDF custom styles, place the following code:
@page big_table {
prince-shrink-to-fit: auto;
}table.big {
page: big_table;
}
Don’t forget to apply the ‘big’ class to the
<table>
element:
<table
class="big">
. For more information about the Prince PDF converter, check out its documentation. - There is a word wrap issue in tables when exporting to PDF. To prevent this, add the following CSS to Appearance->Custom Styles (make sure you navigate to the PDF page using the dropdown menu at the top). If you have added the boilerplate CSS to both the Web and PDF Custom Styles, you are already covered:
/*normal word wrap in tables*/
td, th {
word-break: normal !important;
overflow-wrap: normal !important;
}
Issues With TablePress Tables (Styling not showing)
By default, tables created in TablePress will render with very minimal styling when exported to PDF. In order to apply styling to these tables, you must apply custom styles (in the PDF section in Appearance->Custom Styles) to the classes generated by TablePress. You can discover these by previewing the table in your web page and inspecting it using your browser’s developer tools (in Chrome you would right click on the table and select “Inspect”). Here is an example that renders a table with a heading having a black background and white lettering, followed by rows with background colour alternating between white and light gray:
/* TablePress styling*/
.tablepress thead tr {
background-color: black;
color: white;
}
.tablepress tbody tr.odd {
background-color: lightgray;
}
.tablepress tbody tr:first-child td {
border-top: none;
}
.tablepress tbody td {
border-top: 1px solid #ddd;
}
Awkward Page Breaks
Exporting to PDF sometimes causes page breaks to occur in awkward places. For ways to exert more control over where page breaks occur, read on!
Pressbooks provides two special classes which can be used to produce section breaks in your PDF exports:
class=”section-break”
can be applied to an element to create a section breakclass=”section-break-page”
can be applied to an element create a section break which includes a page break after the section break
You can also force a page break in your PDF exports before or after any block-level element (like a paragraph or heading) by adding class=”page-break-before” or class=”page-break-after” to the desired element.
<h2 class="page-break-before">A heading which will have a page break before it is rendered</h>
<p class="page-break-after">This is a paragraph which will have a page break after it is rendered!</p>
To add a blank page to your PDF export you can add the following markup:
<div class="blank-page">*</div>
Note: The “*” won’t be displayed and is simply included as placeholder text.
Images Appear Pixelated / Low Resolution
“Apply Special Formatting” from Pressbooks User Guide by Pressbooks is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.