Solved

dom pdf header, new page

Posted on 2010-08-27
3
1,819 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
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.

751 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