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

Convert from URL

Typeset.sh is unable to convert an URL into HTML, but it can be easily accomplished using PHP. When using relative paths in your HTML, ensure to set the appropriate base path for resolving those URLs.

// Make sure this is a trusted path!
$url = 'https://typeset.sh/samples/invoice.html';
$base = dirname($url);
$urlResolver = \Typesetsh\UriResolver::all(null, $base, [__DIR__.'/public']);

// Alternativly you could use \Typesetsh\Resource\Cache class as well for this.
$html = file_get_contents($url);

$result = \Typesetsh\createPdf($html, $urlResolver);
$result->toFile(__DIR__.'/invoice.pdf');
PreviousBleed areaNextDocument Metadata

Last updated 2 years ago