Convert from URL 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 = '';
$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);

Last updated