Solved

dom pdf header, new page

Posted on 2010-08-27
3
1,751 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 108

Accepted Solution

by:
Ray Paseur earned 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now