Pdf:Unfolding: Difference between revisions
(Created page with "=Unfolding= A zine and demonstration page to share how we use wiki-to-print to turn wiki pages into PDFs! This page is the main page of the zine, it's where we unfold many different wiki pages into one. This single wiki page is then rendered into HTML and a PDF, for which we use CSS print techniques to make the layout. =CSS print= {{:CSS Print}} =Running wiki-to-print on a server= {{:Running wiki-to-print on the server}} =Colophon=") |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<div id="cover"> | |||
=Unfolding= | =Unfolding= | ||
[[File:Wiki-to-print.gv.svg|200px]] | |||
A zine and demonstration page to share how we use wiki-to-print to turn wiki pages into PDFs! | A zine and demonstration page to share how we use wiki-to-print to turn wiki pages into PDFs! | ||
| Line 6: | Line 9: | ||
This single wiki page is then rendered into HTML and a PDF, for which we use CSS print techniques to make the layout. | This single wiki page is then rendered into HTML and a PDF, for which we use CSS print techniques to make the layout. | ||
__NOTOC__ | |||
</div> | |||
=CSS print= | =CSS print= | ||
Latest revision as of 14:53, 14 November 2025
Unfolding
A zine and demonstration page to share how we use wiki-to-print to turn wiki pages into PDFs!
This page is the main page of the zine, it's where we unfold many different wiki pages into one.
This single wiki page is then rendered into HTML and a PDF, for which we use CSS print techniques to make the layout.
CSS print
@page
@page {
size: A5 portrait;
margin: 10mm;
}
@page:right @page:left
@page:right {
margin-left: 3cm; /*inner*/
margin-right: 1cm; /*outer*/
@bottom-right {
content: "Testing 123!!!";
}
@bottom-center {
content: "Testing margin notes";
}
}
@page:left {
margin-right: 10mm; /*inner*/
margin-left: 15mm; /*outer*/
@bottom-left {
content: "Testing margin notes";
}
@bottom-center {
content: "More margin notes";
}
}
@page custom sections
@page custom{
background-color: lightyellow;
@bottom-center {
content: "A custom note in the bottom-center margin :)";
}
}
section#custom{
page: custom;
}
@page:first
@page:first {
@bottom-center {
content: "";
}
@bottom-right {
content: "";
}
}
@page:nth()
@page:nth(3) {
background-color: pink;
}
pagenumbers
@page{
@bottom-left{
content: counter(page);
}
}
pagebreaks
Force page breaks before each h1:
h1 {
break-before: always;
}
Start a section on the right page:
section {
break-before: right;
}
hyphens
html{
hyphens: auto;
hyphenate-limit-chars: 8;
}
display links in print
a[href]:after {
content: ' (' attr(href) ')';
}
generated pagenumbers in a table of contents
See: https://pagedjs.org/documentation/-cross-references/#target-counter()
#toc a::after {
content: "page: " target-counter(attr(href url), page);
}
Links
Paged Media CSS references:
Using media queries: @media print, @media screen
- https://developer.mozilla.org/en-US/docs/Web/CSS/@media
- https://developer.mozilla.org/en-US/docs/Web/Guide/Printing
Paged.js documentation:
Other links:
- W3C CSS Print Community Group (launched in 2020, closed in December 2023)
- https://www.pagedmedia.org/library/ list of Javascript tools for pagination, hyphenation, baselines, kerning, font resizing, post-production, etc
- reload-in-place.js made by Nicolas Taffin, you're fingers will be so thankful for using this!!
Running wiki-to-print on a server
Official disclaimer: Many things can happen, 502 errors fly around your ears, wiki-to-print is not a product :) as long as it keeps running we're happy.
BUT...
If you're stuck, this may be of use.
Wiki-to-print as a service
Wiki-to-print is a Flask application that runs in the background as a service, using a systemd service file.
$ sudo service wiki2print status $ sudo service wiki2print start $ sudo service wiki2print stop $ sudo service wiki2print restart
- The service is configured at:
/etc/systemd/system/wiki-to-print.service - Here is an example of that file: https://git.vvvvvvaria.org/varia/wiki-to-print/src/branch/master/wiki-to-print.service.example
Debugging
For debugging (on the server)
Stop the wiki2print service:
$ sudo service wiki2print stop
Then run wiki-to-print manually from the folder where it is installed. First go to this folder:
$ cd /var/www/wiki-to-print/wiki-to-print/
And then run the application:
$ make server
And if needed, you can add print statements in the python files to dive deeper into the code.
For debugging (through a local installation)
$ git clone ssh://gitea@vvvvvvaria.org:12345/varia/wiki-to-print.git
$ cd wiki-to-print/wiki-to-print/web-interface/
$ make setup
$ make local
jobrunner
MediaWiki comes with a maintenance script called RunJobs.php that writes changes to the database. The job queue is a built-in feature of MediaWiki that is made to increase the performance on large wikis.
On CC we use a script called jobrunner.sh in /var/www/html/wiki/ that is based on: https://www.mediawiki.org/wiki/Manual:Job_queue#Continuous_service
It runs the MediaWiki maintenance script RunJobs.php every 10 seconds.
It is installed on CC and runs in the background as a systemd service, called "jobrunner", which can be used with:
$ sudo service jobrunner status $ sudo service jobrunner start $ sudo service jobrunner stop $ sudo service jobrunner reload
- The service is configured at:
/etc/systemd/system/jobrunner.service - This is an example of the service file:
[Unit] Description=MediaWiki Job runner [Service] ExecStart=/var/www/html/wiki/jobrunner.sh Nice=10 ProtectSystem=full User=www-data OOMScoreAdjust=200 StandardOutput=journal [Install] WantedBy=multi-user.target