How to set the pagemargins of a PDF file?

Sep 29, 2010 at 8:46 AM
Edited Sep 29, 2010 at 8:47 AM

How do i set the pagemargins of a PDF file?

i've googled and only found this: 

$sheet = &$objPHPExcel->setActiveSheetIndex(0); 
$pageMargins = &$sheet->getPageMargins();
$margin = 0.2 / 2.54;
$pageMargins->setTop($margin);
$pageMargins->setBottom($margin); 
$pageMargins->setLeft($margin); 
$pageMargins->setRight($margin);

which obviously doesn't work

 

Coordinator
Sep 29, 2010 at 9:09 AM

The PDF Writer currently doesn't support margins (or headers/footers). This is still an ongoing work in progress. The most recent changes have been support for paper size and orientation, and I was going to work on margins with the next changes to that particular piece of code.

Sep 29, 2010 at 9:22 AM

Hey Mark, tnx for the quick reply

I'm going to use the default margins for now then.

Great to hear this is on the list.

Jun 2, 2012 at 9:28 PM

Sorry to bump an old thread but has the situation with headers/footers in PDF changed? I know they can be done in tcPDF but wondered if you had brought them over to PHPExcel yet?

Thanks

Jason

Coordinator
Jun 4, 2012 at 12:06 PM
Edited Jun 4, 2012 at 12:30 PM

You might be aware from reading the roadmap or following me on twitter (and if viewing the SVN repository commits) that the PDF writing is currently being rewritten. This is still an active work in progress, I've only just completed the first step, but my next task is looking through all the outstanding PDF tasks and implementing them in the appropriate manner for the three different libraries that are now supported for PDF rendering. i.e. it I am now actively working on that area of the code again.

Double checking the code, looks like I've already implemented setting page margins for the PDF files.