mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
Better PDF export mechanism (part I) (#7399)
This commit is contained in:
85
docs/User Guide/!!!meta.json
vendored
85
docs/User Guide/!!!meta.json
vendored
@@ -3472,7 +3472,7 @@
|
||||
"BFs8mudNFgCS",
|
||||
"NRnIZmSMc5sj"
|
||||
],
|
||||
"title": "Export as PDF",
|
||||
"title": "Printing & Exporting as PDF",
|
||||
"notePosition": 120,
|
||||
"prefix": null,
|
||||
"isExpanded": false,
|
||||
@@ -3503,13 +3503,62 @@
|
||||
{
|
||||
"type": "label",
|
||||
"name": "iconClass",
|
||||
"value": "bx bxs-file-pdf",
|
||||
"value": "bx bx-printer",
|
||||
"isInheritable": false,
|
||||
"position": 30
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "CohkqWQC1iBv",
|
||||
"isInheritable": false,
|
||||
"position": 40
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "0ESUbbAxVnoK",
|
||||
"isInheritable": false,
|
||||
"position": 50
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "KSZ04uQ2D1St",
|
||||
"isInheritable": false,
|
||||
"position": 60
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "6f9hih2hXXZk",
|
||||
"isInheritable": false,
|
||||
"position": 70
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "AlhDUqhENtH7",
|
||||
"isInheritable": false,
|
||||
"position": 80
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "GTwFsgaA0lCt",
|
||||
"isInheritable": false,
|
||||
"position": 90
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "zP3PMqaG71Ct",
|
||||
"isInheritable": false,
|
||||
"position": 100
|
||||
}
|
||||
],
|
||||
"format": "markdown",
|
||||
"dataFileName": "Export as PDF.md",
|
||||
"dataFileName": "Printing & Exporting as PDF.md",
|
||||
"attachments": [
|
||||
{
|
||||
"attachmentId": "NfSjRsArIQHy",
|
||||
@@ -3517,7 +3566,7 @@
|
||||
"role": "image",
|
||||
"mime": "image/png",
|
||||
"position": 10,
|
||||
"dataFileName": "Export as PDF_image.png"
|
||||
"dataFileName": "Printing & Exporting as PD.png"
|
||||
},
|
||||
{
|
||||
"attachmentId": "Om2EmdZr54vy",
|
||||
@@ -3525,7 +3574,7 @@
|
||||
"role": "image",
|
||||
"mime": "image/png",
|
||||
"position": 10,
|
||||
"dataFileName": "1_Export as PDF_image.png"
|
||||
"dataFileName": "1_Printing & Exporting as PD.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -8758,51 +8807,51 @@
|
||||
"mime": "text/html",
|
||||
"attributes": [
|
||||
{
|
||||
"type": "label",
|
||||
"name": "iconClass",
|
||||
"value": "bx bx-slideshow",
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "BlN9DFI679QC",
|
||||
"isInheritable": false,
|
||||
"position": 10
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "BlN9DFI679QC",
|
||||
"value": "OFXdgB2nNk1F",
|
||||
"isInheritable": false,
|
||||
"position": 20
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "OFXdgB2nNk1F",
|
||||
"value": "R9pX4DGra2Vt",
|
||||
"isInheritable": false,
|
||||
"position": 30
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "R9pX4DGra2Vt",
|
||||
"value": "0ESUbbAxVnoK",
|
||||
"isInheritable": false,
|
||||
"position": 40
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "0ESUbbAxVnoK",
|
||||
"value": "grjYqerjn243",
|
||||
"isInheritable": false,
|
||||
"position": 50
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "s1aBHPd79XYj",
|
||||
"value": "AlhDUqhENtH7",
|
||||
"isInheritable": false,
|
||||
"position": 60
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "grjYqerjn243",
|
||||
"value": "s1aBHPd79XYj",
|
||||
"isInheritable": false,
|
||||
"position": 70
|
||||
},
|
||||
@@ -8814,11 +8863,11 @@
|
||||
"position": 80
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"name": "internalLink",
|
||||
"value": "AlhDUqhENtH7",
|
||||
"type": "label",
|
||||
"name": "iconClass",
|
||||
"value": "bx bx-slideshow",
|
||||
"isInheritable": false,
|
||||
"position": 90
|
||||
"position": 10
|
||||
}
|
||||
],
|
||||
"format": "markdown",
|
||||
|
||||
|
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 150 B |
@@ -1,38 +0,0 @@
|
||||
# Export as PDF
|
||||

|
||||
|
||||
Screenshot of the note contextual menu indicating the “Export as PDF” option.
|
||||
|
||||
On the desktop application of Trilium it is possible to export a note as PDF. On the server or PWA (mobile), the option is not available due to technical constraints and it will be hidden.
|
||||
|
||||
To print a note, select the  button to the right of the note and select _Export as PDF_.
|
||||
|
||||
Afterwards you will be prompted to select where to save the PDF file.
|
||||
|
||||
## Automatic opening of the file
|
||||
|
||||
When the PDF is exported, it is automatically opened with the system default application for easy preview.
|
||||
|
||||
Note that if you are using Linux with the GNOME desktop environment, sometimes the default application might seem incorrect (such as opening in GIMP). This is because it uses Gnome's “Recommended applications” list.
|
||||
|
||||
To solve this, you can change the recommended application for PDFs via this command line. First, list the available applications via `gio mime application/pdf` and then set the desired one. For example to use GNOME's Evince:
|
||||
|
||||
```
|
||||
gio mime application/pdf
|
||||
```
|
||||
|
||||
## Reporting issues with the rendering
|
||||
|
||||
Should you encounter any visual issues in the resulting PDF file (e.g. a table does not fit properly, there is cut off text, etc.) feel free to [report the issue](../../Troubleshooting/Reporting%20issues.md). In this case, it's best to offer a sample note (click on the  button, select Export note → This note and all of its descendants → HTML in ZIP archive). Make sure not to accidentally leak any personal information.
|
||||
|
||||
## Landscape mode
|
||||
|
||||
When exporting to PDF, there are no customizable settings such as page orientation, size, etc. However, it is possible to specify a given note to be printed as a PDF in landscape mode by adding the `#printLandscape` attribute to it (see <a class="reference-link" href="../../Advanced%20Usage/Attributes.md">Attributes</a>).
|
||||
|
||||
## Page size
|
||||
|
||||
By default, the resulting PDF will be in Letter format. It is possible to adjust it to another page size via the `#printPageSize` attribute, with one of the following values: `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`.
|
||||
|
||||
## Keyboard shortcut
|
||||
|
||||
It's possible to trigger the export to PDF from the keyboard by going to _Keyboard shortcuts_ in <a class="reference-link" href="../UI%20Elements/Options.md">Options</a> and assigning a key combination for the `exportAsPdf` action.
|
||||
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
75
docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.md
vendored
Normal file
75
docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.md
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# Printing & Exporting as PDF
|
||||
<figure class="image"><img style="aspect-ratio:951/432;" src="Printing & Exporting as PD.png" width="951" height="432"><figcaption>Screenshot of the note contextual menu indicating the “Export as PDF” option.</figcaption></figure>
|
||||
|
||||
## Printing
|
||||
|
||||
This feature allows printing of notes. It works on both the desktop client, but also on the web.
|
||||
|
||||
Note that not all note types are printable as of now. We do plan to increase the coverage of supported note types in the future.
|
||||
|
||||
To print a note, select the <img src="1_Printing & Exporting as PD.png" width="29" height="31"> button to the right of the note and select _Print note_. Depending on the size and type of the note, this can take up to a few seconds. Afterwards you will be redirected to the system/browser printing dialog.
|
||||
|
||||
> [!NOTE]
|
||||
> Printing and exporting as PDF are not perfect. Due to technical limitations, and sometimes even browser glitches the text might appear cut off in some circumstances.
|
||||
|
||||
## Reporting issues with the rendering
|
||||
|
||||
Should you encounter any visual issues in the resulting PDF file (e.g. a table does not fit properly, there is cut off text, etc.) feel free to [report the issue](../../Troubleshooting/Reporting%20issues.md). In this case, it's best to offer a sample note (click on the <img src="1_Printing & Exporting as PD.png" width="29" height="31"> button, select Export note → This note and all of its descendants → HTML in ZIP archive). Make sure not to accidentally leak any personal information.
|
||||
|
||||
Consider adjusting font sizes and using [page breaks](../../Note%20Types/Text/Insert%20buttons.md) to work around the layout.
|
||||
|
||||
## Exporting as PDF
|
||||
|
||||
On the desktop application of Trilium it is possible to export a note as PDF. On the server or PWA (mobile), the option is not available due to technical constraints and it will be hidden.
|
||||
|
||||
To print a note, select the  button to the right of the note and select _Export as PDF_. Afterwards you will be prompted to select where to save the PDF file.
|
||||
|
||||
### Automatic opening of the file
|
||||
|
||||
When the PDF is exported, it is automatically opened with the system default application for easy preview.
|
||||
|
||||
Note that if you are using Linux with the GNOME desktop environment, sometimes the default application might seem incorrect (such as opening in GIMP). This is because it uses Gnome's “Recommended applications” list.
|
||||
|
||||
To solve this, you can change the recommended application for PDFs via this command line. First, list the available applications via `gio mime application/pdf` and then set the desired one. For example to use GNOME's Evince:
|
||||
|
||||
```
|
||||
gio mime application/pdf
|
||||
```
|
||||
|
||||
### Customizing exporting as PDF
|
||||
|
||||
When exporting to PDF, there are no customizable settings such as page orientation, size. However, there are a few <a class="reference-link" href="../../Advanced%20Usage/Attributes.md">Attributes</a> to adjust some of the settings:
|
||||
|
||||
* To print in landscape mode instead of portrait (useful for big diagrams or slides), add `#printLandscape`.
|
||||
* By default, the resulting PDF will be in Letter format. It is possible to adjust it to another page size via the `#printPageSize` attribute, with one of the following values: `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid`, `Ledger`.
|
||||
|
||||
> [!NOTE]
|
||||
> These options have no effect when used with the printing feature, since the user-defined settings are used instead.
|
||||
|
||||
## Keyboard shortcut
|
||||
|
||||
It's possible to trigger both printing and export as PDF from the keyboard by going to _Keyboard shortcuts_ in <a class="reference-link" href="../UI%20Elements/Options.md">Options</a> and assigning a key combination for:
|
||||
|
||||
* _Print Active Note_
|
||||
* _Export Active Note as PDF_
|
||||
|
||||
## Constraints & limitations
|
||||
|
||||
Not all <a class="reference-link" href="../../Note%20Types.md">Note Types</a> are supported when printing, in which case the _Print_ and _Export as PDF_ options will be disabled.
|
||||
|
||||
* For <a class="reference-link" href="../../Note%20Types/Code.md">Code</a> notes:
|
||||
* Line numbers are not printed.
|
||||
* Syntax highlighting is enabled, however a default theme (Visual Studio) is enforced.
|
||||
* For <a class="reference-link" href="../../Note%20Types/Collections.md">Collections</a>:
|
||||
* Only <a class="reference-link" href="../../Note%20Types/Collections/Presentation%20View.md">Presentation View</a> is currently supported.
|
||||
* We plan to add support for all the collection types at some point.
|
||||
* Using <a class="reference-link" href="../../Theme%20development/Custom%20app-wide%20CSS.md">Custom app-wide CSS</a> for printing is not longer supported, due to a more stable but isolated mechanism.
|
||||
* We plan to introduce a new mechanism specifically for a print CSS.
|
||||
|
||||
## Under the hood
|
||||
|
||||
Both printing and exporting as PDF use the same mechanism: a note is rendered individually in a separate webpage that is then sent to the browser or the Electron application either for printing or exporting as PDF.
|
||||
|
||||
The webpage that renders a single note can actually be accessed in a web browser. For example `http://localhost:8080/#root/WWRGzqHUfRln/RRZsE9Al8AIZ?ntxId=0o4fzk` becomes `http://localhost:8080/?print#root/WWRGzqHUfRln/RRZsE9Al8AIZ`.
|
||||
|
||||
Accessing the print note in a web browser allows for easy debugging to understand why a particular note doesn't render well. The mechanism for rendering is similar to the one used in <a class="reference-link" href="Note%20List.md">Note List</a>.
|
||||
@@ -19,7 +19,7 @@ This section presents the most important changes by version. For a full set of c
|
||||
* v0.92.4:
|
||||
* macOS binaries are now signed.
|
||||
* <a class="reference-link" href="Note%20Types/Text.md">Text</a> notes can now have adjustable <a class="reference-link" href="Note%20Types/Text/Content%20language%20%26%20Right-to-le.md">Content language & Right-to-left support</a>.
|
||||
* <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Export%20as%20PDF.md">Export as PDF</a>
|
||||
* <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Printing%20%26%20Exporting%20as%20PDF.md">Export as PDF</a>
|
||||
* <a class="reference-link" href="Basic%20Concepts%20and%20Features/Zen%20mode.md">Zen mode</a>
|
||||
* <a class="reference-link" href="Note%20Types/Collections/Calendar%20View.md">Calendar View</a>, allowing notes to be displayed in a monthly grid based on start and end dates.
|
||||
* v0.91.5:
|
||||
|
||||
@@ -53,7 +53,7 @@ Alternatively, it's possible to insert a horizontal ruler by typing `---`.
|
||||
|
||||
<figure class="image image-style-align-right"><img style="aspect-ratio:371/79;" src="8_Insert buttons_image.png" width="371" height="79"></figure>
|
||||
|
||||
Page breaks provide a way to force the next paragraph or block (table, image, etc.) to be displayed onto the next page when printing (either to a real printer to [when exporting to PDF](../../Basic%20Concepts%20and%20Features/Notes/Export%20as%20PDF.md)).
|
||||
Page breaks provide a way to force the next paragraph or block (table, image, etc.) to be displayed onto the next page when printing (either to a real printer to [when exporting to PDF](../../Basic%20Concepts%20and%20Features/Notes/Printing%20%26%20Exporting%20as%20PDF.md)).
|
||||
|
||||
Page breaks are marked in the editor with the words _Page break_, but they will not actually be shown when printed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user