3

I generate a excel 2007 file and output it as PDF with mPDF. Ive used the PHPExcel example files as a starting point. I use xlsx template files to generate the excel files that hold images, some text and text styles.

The generated xlsx files is good. But the PDF is not! The first page has different (narrower) margin than the rest and is uneven on all pages.

I've tried different things in the php file that generate xlsx (before mPdf). Nothing is working or changing anything. All code examples are taken straight from the PHPExcel documentation:

// doesnt work! $objPHPExcel->getActiveSheet()->getPageMargins()->setTop(0.1); $objPHPExcel->getActiveSheet()->getPageMargins()->setRight(0.1); $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft(0.1); $objPHPExcel->getActiveSheet()->getPageMargins()->setBottom(0.1); // doesnt work! $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1); $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0); // doesnt work! $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); 

So none of this changes or does what it promises.

I CAN do something though:

// works! $objPHPExcel->setActiveSheetIndex(0)->setShowGridlines(false); // works! $objPHPExcel->getActiveSheet()->getStyle('A1:' . $objPHPExcel->getActiveSheet()->getHighestColumn() . $objPHPExcel->getActiveSheet()->getHighestRow())->getFont()->setSize(9); 

I also tried to configure layout in the Classes/PHPExcel/Writer/PDF/mpdf.php:

// doesnt work! $paperSize = 'A4'; // doesnt work! $pdf = new mPDF('win-1252', 'A4', 8, 'DejaVuSansCondensed', 15, 15, 15, 15, 8, 8); 

So I don't know what to do. Some works, most doesnt.... Any help would be highly appreciated!

1 Answer 1

0

Page orientation and paper size should work with all PDF writers; page margins are only supported by the tcPDF writer, not by mPDF or DomPDF; page setup features are MS Excel page setup features, and are not implemented in the PDF writers.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.