This is an archived forum post. The information may be outdated. Contact us if you have any questions.

pdfcrowd not functionally with my page

siriuxs wrote on 2017-08-28:
Hi, I'm trying to convert this html page https://www.magazzinoperfetto.it/test/fattura/green.html with this page https://www.magazzinoperfetto.it/test/index.php

The code that I used is:

<?php
require 'pdfcrowd.php';

try
{   
    // create an API client instance
    $client = new Pdfcrowd("siriuxs", "56f244f7408025bcecf03192f718da3f");

    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI('https://www.magazzinoperfetto.it/test/fattura/green.html');
    $client->setPageWidth("210mm");
	$client->setPageHeight("297mm");
	$client->setInitialPdfZoomType(Pdfcrowd::FIT_PAGE);
	$client->setPageLayout(Pdfcrowd::CONTINUOUS);

    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: max-age=0");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"google_com.pdf\"");

    // send the generated PDF 
    echo $pdf;
}
catch(PdfcrowdException $why)
{
    echo "Pdfcrowd Error: " . $why;
}
?>


As you can see, the result isn't not what I see in the html page. Why? I want the incoice in a single pdf page
support wrote on 2017-08-29:
Hello,

Options
$client->setInitialPdfZoomType(Pdfcrowd::FIT_PAGE)
$client->setPageLayout(Pdfcrowd::CONTINUOUS);
just influence the default layout in PDF viewer. They don't effect the size of converted PDF.
Try to use setPdfScalingFactor, e.g. set to 0.6, for shrinking your document.
Also you can try to reset margins to 0 (setPageMargins method).

Details are here:
https://pdfcrowd.com/api/html-to-pdf-php/#setPdfScalingFactor