Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

dom pdf header, new page

Posted on 2010-08-27
3
Medium Priority
?
1,945 Views
Last Modified: 2012-05-10
i am using dompdf to export my html into pdf. iam using inline php.

i wanted 2 display header and footer on each page. i was able to add page number to page page but i was not able 2 add image.

here is the code


$html .='<script type="text/php">
$font = Font_Metrics::get_font("verdana", "bold");
$pdf->page_text(270, 820, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 10, array(0,0,0));
$pdf->page_text(390, 820, "Copyright © RefCheck- All Rights Reserved", $font, 10, array(0,0,0));
$footer = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
$y = $h - 2 * $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 1);
$pdf->image("http://localhost/ref_check/images/reference.png",".png",50,100,1050,150);
$pdf->close_object();
$pdf->add_object($footer, "all");
</script>';

can you tell me what am i doing wrong here. also the output generated is a table, which when spanned on more than one page breaks. i am using version 0.51 of dompdf
0
Comment
Question by:nandananushil1
3 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 33547631
It appears you're trying to use PHP on the client side???

Why exactly is your PHP wrapped in script tags?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 33549401
You might want to use the more popular industry standard, "fpdf" (google it).  Here is why...

HTML is a markup language.  PDF is a page-layout language.  These are as different as computer screens and paper, which they are intended for, respectively.  While HTML has been used by eager designers to attempt "page layout" on the browser viewport, it has been a largely unsuccessful exercise.  Thus new versions of HTML and CSS have evolved to give us a little more control.  But the simple fact remains: browser layout and output is largely imprecise, whereas page layout can be accomplished to the 1/100 inch tolerance.

The second part of "why" is the client perception.  You will not have this dompdf strategy in place for a week before you will get a call from someone who says, "I tried it and my PDF does not look like my screen."  In other words, it creates the impression that you can replicate the browser output on paper, and you cannot - the different media have different uses and conventions.

Good luck with it, ~Ray

0
 

Author Comment

by:nandananushil1
ID: 33550877
Ray i personally want to thank you for suggesting fpdf. i have been using it for past 3-4 hours and i am already close to my desired output. thank you so much
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question