Typeset.sh
HomeNewsDemoPricing
  • Getting started
    • Installation
    • Using typeset.sh
    • First template
    • CSS and paged media
      • Page counters
      • Page selectors
      • Page groups
      • Running elements
      • Bleed area
    • Convert from URL
    • Document Metadata
    • Changelog
  • Advanced guides
    • QR codes
    • Save handlers
    • Error handling
    • Signing a PDF
    • PDF Standards
      • ZUGFeRD
      • PDF/A
      • PDF/UA
      • PDF/X-4
    • Color profiles
    • JavaScript
    • Common Object/Classes
      • createPdf function
      • HtmlToPdf
      • Result Object
Powered by GitBook
On this page
  1. Getting started

First template

All layout configurations are done using CSS.

If you are accustomed to configuring page size and other document aspects (such as fonts) using PHP with other PDF renderers, you will appreciate the ability to do so using CSS and the official Print-CSS syntax with typeset.sh.

The following example shows how to create a simple A5 page using a Google font:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My first template</title>
<style>
    @import url('https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');
    @page {
        size: A5;
        margin: 10mm;
    }
</style>
</head>
<body>
    Hello World
</body>
</html>

All layout-related configurations are done using CSS inside your document. The official CSS standard includes special properties and rules for printed and paged media such as PDF.

PreviousUsing typeset.shNextCSS and paged media

Last updated 2 years ago

For more information on paged media in CSS, refer to the official W3.org reference at .

https://www.w3.org/TR/2018/WD-css-page-3-20181018/