You can use the TCPDF library in PHP to generate a PDF from a remote URL.
The PHP script below is basic and may fail on pages with forms and other complex code. Here’s an example script:
<?php
require_once('tcpdf/tcpdf.php');
// Create a new TCPDF object
$pdf = new TCPDF();
// Get the HTML content from a remote URL
$html = file_get_contents('https://antennasurveys.com');
// Set the PDF's title and author
$pdf->SetTitle('PHP to PDF Example');
$pdf->SetAuthor('QikPDF.com');
// Add a page to the PDF
$pdf->AddPage();
// Write the HTML content to the PDF
$pdf->writeHTML($html, true, false, true, false, '');
// Output the PDF to the browser. I=inline, D=download
$pdf->Output('pdf_from_url.pdf', 'I');
?>
This script will create a PDF file from the HTML content of the specified URL and output it to the browser as a download. You will need the TCPDF library to use this PHP script. If you know how to use composer, install TCPDF from this link.
In the above script example, you should have the “tcpdf” folder in same directory as the example.
If you do not know how to use composer, we HIGHLY recommend you learn how to. The composer site is a great place to start.
For those that are not “code heads”, we have complied TCPDF 6 and can be downloaded here.
There are official TCPDF examples located here.
We scan all of our files, but you are downloading at your own risk. It is YOUR responsibility to scan ALL files that you download from the internet.