Paged Media CSS examples: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 1: Line 1:
=@page=
=@page=


Line 137: Line 139:
= Links =
= Links =


Paged Media CSS references
==Paged Media CSS references==


* https://developer.mozilla.org/en-US/docs/Web/CSS/Paged_Media
* https://developer.mozilla.org/en-US/docs/Web/CSS/Paged_Media
* https://www.princexml.com/doc/paged/


html2print PDF engines
==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


* https://www.pagedjs.org/
==web-to-print PDF rendering engines==
* https://weasyprint.readthedocs.io/
* https://pandoc.org/


PDF-generating oneliners  
* Paged.js https://www.pagedjs.org/
* Weasyprint https://weasyprint.readthedocs.io/
* Reportlab (Python Library) https://www.reportlab.com/
* Prince https://www.princexml.com/
* LaTeX https://www.latex-project.org/
* ConTeXt  https://wiki.contextgarden.net/Main_Page
* wkhtmltopdf https://wkhtmltopdf.org/
 
==PDF-generating oneliners ==


  $ pandoc -f markdown --pdf-engine weasyprint -c stylesheet.css filename.md -o filename.pdf
  $ pandoc -f markdown --pdf-engine weasyprint -c stylesheet.css filename.md -o filename.pdf


  $ weasyprint -s stylesheet.css filename.html filename.pdf
  $ weasyprint -s stylesheet.css filename.html filename.pdf
==Paged.js workshop==
(13 October 2022)
* https://pad.xpub.nl/p/pagedjs
* [https://media.xpub.nl/2022/2022-10-13-pagedjs.html Recording of the presentation by Julie Blanc and Julien Taquet]


[[Category:Cookbook]]
[[Category:Cookbook]]
[[Category:PagedMedia]]
[[Category:PagedMedia]]

Revision as of 10:55, 17 March 2023


@page

@page {
  size: A5 portrait;
}

@page:right @page:left

@page:right {
  margin-left: 3cm; /*inner*/
  margin-right:1cm; /*outer*/ 
  
  @bottom-right {
    content: "Testing 123!!!";
  }
  
  @bottom-center {
    content: "Testing WeasyPrint";
  }
}

@page:left {
  margin-right: 10mm; /*inner*/
  margin-left: 15mm; /*outer*/

  @bottom-left {
    content: "Testing WeasyPrint";
  }

  @bottom-center {
    content: "Testing WeasyPrint";
  }
}

@page customsection

@page custom{
  background-color: lightyellow;
  
  @bottom-center {
    content: "Testing WeasyPrint";
  }
}

section#custom{
  page: customsection;
}

@page:first

@page:first {
  @bottom-center { 
    content: ""; 
  }
  @bottom-right { 
    content: ""; 
  }
}

@page:customsection

@page customsection {
  background-color: pink;

  @top-center { 
    content: "Hello :)"; 
  }
}

section#custom{
  page: customsection;
}


pagenumbers

@page{

    @bottom-left{
        content: counter(page);
    }
}

pagebreaks

Force page breaks before each h1

<source lang="css">
h1 {
  page-break-before: always;
}

Start a section on the right page

section {
  page-break-before: right;
}

hyphens

html{
    hyphens: auto;
    hyphenate-limit-chars: 8;
}

display links in print

a[href]:after {
	content: ' (' attr(href) ')';
}


Links

Paged Media CSS references

Using media queries: @media print, @media screen

web-to-print PDF rendering engines

PDF-generating oneliners

$ pandoc -f markdown --pdf-engine weasyprint -c stylesheet.css filename.md -o filename.pdf
$ weasyprint -s stylesheet.css filename.html filename.pdf

Paged.js workshop

(13 October 2022)