We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,613 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Changing Top Margins on Second Page with FPDF

Hello,
This is about a PHP PDF utility called "FPDF." Can anyone tell me if it is possible to change the margins on the second page of a PDF using the library. I set the margins on the first page, but because the first page has a letterhead, it starts about 2.5" down the page. When I come to the second page, I tried to reset the margins, but it does not appear to accept a reset. I am new at using FPDF, so I'm probably missing something. Here is my code:

$pdf = new PDF();
// First page
$pdf->SetMargins(25,65,25);
$pdf->AddPage();
$pdf->SetFont('Arial','',20);
$pdf->SetFontSize(12);
$pdf->Image('../../Old-Web/images/Foundation-Logo_new.gif',81,5,48,0,'GIF');
$html="Some Text";
$pdf->WriteHTML($html);
//Second Page
$pdf->AddPage();
$pdf->SetTopMargin(25);
$htmp="Some More Text";
$pdf->WriteHTML($html);
$pdf->Close();

The PDF is generated correctly with all text, images, etc., but the second page has a large white space at the top where the letterhead was. I've also tried reusing "SetMargins(25,25,25)" on the second page, also with no results.

Any help would be greatly appreciated.

2
Contributors
1
Reply
1 Month
Discussion Span
7 Months Ago
Last Updated
2
Views
visualmonk
Newbie Poster
11 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

try to add this $pdf->SetY(-25); after 12th line in your code. Lets try and let me know if it not working.

rayidi
Junior Poster in Training
83 posts since May 2011
Reputation Points: 13
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0887 seconds using 2.66MB