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

Set Page Margins are not working. what I am missing?

andro123 wrote on 2016-06-14:
$pdfcrowd->setPageMargins("2in", "0.35in", "0.35in", "0.35in");
support wrote on 2016-06-16:
Hello,

Could you please post here your complete code that calls our API?
andro123 wrote on 2016-06-17:
// Trigger
$get_url = urldecode( $_GET['get_url'] );

// Build
require_once( 'inc/pdfcrowd.php' );
try {
// create an API client instance
$pdfcrowd = new Pdfcrowd( PDFCROWD_USERNAME, PDFCROWD_API_KEY );
$pdfcrowd->setPageWidth( "8.5in" );
$pdfcrowd->setPageHeight( "11in" );
//$pdfcrowd->setHorizontalMargin( ".50in" );
//$pdfcrowd->setVerticalMargin( "1.20in" );
$pdfcrowd->setPageMargins("1.35in", ".35in", "1in", ".35in");
$pdfcrowd->setHeaderHtml('
<img alt="Reinhart Logo" src="'.plugin_dir_url( __FILE__ ).'/images/logo.jpg" style="width:184px;height:50px;display:block;margin:41px 11px 0">
');
$pdfcrowd->usePrintMedia( true );
$pdfcrowd->enableJavaScript( false );
$pdf = $pdfcrowd->convertURI( $get_url );

// set filename
$get_url_pieces = explode( '?', $get_url );
$get_url = $get_url_pieces[0];
if ( substr($get_url, -1, 1) == "/" ) { $get_url = substr( $get_url, 0, -1 ); }
$pdf_name = end( explode('/', $get_url) ) . '.pdf';


// set HTTP response headers
header( "Content-Type: application/pdf" );
header( "Cache-Control: no-cache" );
header( "Accept-Ranges: none" );
header( "Content-Disposition: attachment; filename=\"".$pdf_name."\"" );

// send the generated PDF
echo $pdf;

} catch( PdfcrowdException $why ) { echo "Error: " . $why; }
support wrote on 2016-06-20:
Hello,

Your code seems correct, the PDF should be generated with the margins specified in setPageMargins. Could you please send us the resulting PDF to support@pdfcrowd.com?
andro123 wrote on 2016-07-01:
I just fix it now. I forgot to use the latest library.

Thanks.