on Image to PDF add margin on working
divsbhalala opened this issue · 6 comments
on Image to PDF add margin is not adding margin o the top and bottom of the page.
Here is the request params. http://prntscr.com/h77qfa
Here is the code
public function convertToPdf($pdfFilePath, $task = 'officepdf', $orientation='portrait', $withMargin=true ,$rotation = [], $name, $pkjFileName){
// you can call task class directly
// to get your key pair, please visit https://developer.ilovepdf.com/user/projects
$ilovepdf = new Ilovepdf( $this->publicKey, $this->secretKey );
// print_r($mergeTask);
$officepdf = $ilovepdf->newTask($task);
if($task == 'imagepdf'){
$officepdf->setPageSize('A4');
$officepdf->setOrientation($orientation);
if($withMargin){
$officepdf->setMargin(40);
}
}
// file var keeps info about server file id, name...
// it can be used latter to cancel file
$fileA = $officepdf->addFile($pdfFilePath);
$fileA->setRotation($rotation);
$officepdf->setOutputFilename($name);
$officepdf->setPackagedFilename($pkjFileName);
// and set name for output file.
// the task will set the correct file extension for you.
// process files
$officepdf->execute();
return $officepdf;
}
If you want to check, you can check here https://www.tweak.com/convert-to-pdf/
Hello divsbhalala,
I have checked this options on our code:
This file is without set margin (a4, portrait, rotation 0 on file):
https://expirebox.com/download/343c7bf3d65c40fcd69b784efc29b3f3.html
This file is with margin (margin 100, a4, portrait, rotation 0 on file)
https://expirebox.com/download/22030df528afb67bf517e9e71ba9f032.html
This is the same file on your site (nice work):
https://expirebox.com/download/250f922d16652d400a89ae6971e4e8cd.html
Maybe you should check if( $withMargin===true ) because i think it's adding always the 40px margin you set.
@maztch I am telling that margin on top and on Bottom is not adding when we set margin
Have you seen the difference between the three pdf listed? Your PDF (using your website, with your form setting to "no margin") result have a margin, you can compare it with the first one that doesn't have margin. You are adding margin always.
@maztch that I am telling if I am adding margin alway then why margin in not apply on Top and Bottom on the PDF
divsbhalala, can you try diferent margin sizes, please? try to set it to 0, 40, and 100, to compare pdf outputs, and check if there is any difference on top and bottom between output files.
@maztch it's working now.
thanks