CSS Print examples: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 90: Line 90:


...
...
==pagenumbers==
<source lang="css">
...
</source>
==hyphens==
<source lang="css">
    hyphens: auto;
    hyphenate-limit-chars: 8;
</source>


==display links in print==
==display links in print==
Line 99: Line 113:




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


html2print PDF engines


* https://www.pagedjs.org/
* https://weasyprint.readthedocs.io/
* https://pandoc.org/ (markdown to PDF oneliner: <code>$ pandoc -f markdown --pdf-engine weasyprint -c stylesheet.css filename.md -o filename.pdf</code>)


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

Revision as of 10:52, 6 July 2021

@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 customsection

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

section#custom{
  page: customsection;
}

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

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

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

@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

...


pagenumbers

...

hyphens

    hyphens: auto;
    hyphenate-limit-chars: 8;

display links in print

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


Links

Paged Media CSS references

html2print PDF engines