Solved

dom pdf header, new page

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

624 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