Paged Media CSS examples: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 21: Line 21:
     content: "Testing WeasyPrint";
     content: "Testing WeasyPrint";
   }
   }
}
</source>
==@page customsection==
<source lang="css">
@page custom{
  background-color: lightyellow;
 
  @bottom-center {
    content: "Testing WeasyPrint";
  }
}
section#custom{
  page: customsection;
}
}
</source>
</source>
Line 54: Line 38:
     content: "Testing WeasyPrint";
     content: "Testing WeasyPrint";
   }
   }
}
</source>
==@page customsection==
<source lang="css">
@page custom{
  background-color: lightyellow;
 
  @bottom-center {
    content: "Testing WeasyPrint";
  }
}
section#custom{
  page: customsection;
}
}
</source>
</source>

Revision as of 11:56, 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: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

...


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

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

display links in print

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


Links

Paged Media CSS references

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