QikPDF https://qikpdf.com The Marketers PDF Creator Software Tue, 03 Sep 2024 20:21:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 https://qikpdf.com/wp-content/uploads/2022/11/qikpdf.com_-150x150.png QikPDF https://qikpdf.com 32 32 PHP Create PDF from Remote URL https://qikpdf.com/php-create-pdf-from-remote-url/ Wed, 01 Feb 2023 23:10:11 +0000 https://qikpdf.com/?p=88 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: This script will create a PDF file from the HTML content of the specified URL and output it […]

The post PHP Create PDF from Remote URL first appeared on QikPDF.

]]>
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.

The post PHP Create PDF from Remote URL first appeared on QikPDF.

]]>