Solved

dom pdf header, new page

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select from sql by results from textbox 8 26
WordPress Themes 10 34
PHP - AJAX and MySQL it works only if the value is a number 12 34
PHP preg_replace code convert to Delphi 14 32
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

919 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

20 Experts available now in Live!

Get 1:1 Help Now