Solved

Generate pdf report in New browser window Drupal

Posted on 2011-03-14
6
689 Views
Last Modified: 2012-05-11
Which TCPDF function should I use in order to generate the pdf in a new browser window?
0
Comment
Question by:vivekpv10
  • 3
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 450 total points
ID: 35127887
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 35127966
In my experience, I have found FPDF.org to be a great resource.  I have not used it with Drupal, but I cannot imagine any reason why it would not work.  The class is very easy to use and very fast.  It allows positioning to within about 1/100 inch (good enough for find graphics on business cards).

When I have used it, I have written the PDF file into the server file system and produced a link to the PDF file in the browser window.  It's easy to set target="_blank" or some similar attribute of the <a> tag that points to the PDF file.

HTH, ~Ray
0
 
LVL 5

Author Comment

by:vivekpv10
ID: 35135318
can anyone pls post sample code...
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 50 total points
ID: 35137798
I can show you the "Hello World" example.  You can see it in action on my server, here:
http://www.laprbass.com/RAY_fpdf_hello_world.php

HTH, ~Ray
<?php // RAY_fpdf_hello_world.php


// DEMONSTRATE THE BASICS OF FPDF


// BRING IN THE PDF THING
require_once('fpdf16/fpdf.php');

// SYNTHESIZE THE PDF FILE NAME
$pdf_file_link = '/RAY_junk/' . 'temp_pdf_color' . '.pdf';
$pdf_file_name = getcwd()     . $pdf_file_link;

// DO THE HELLO WORLD EXERCISE IN WHITE ON A BLUE BACKGROUND
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetFillColor(0,0,255);
$pdf->SetTextColor(255,255,255);
$pdf->Cell(40,10,'Hello World!',0,2,'L', TRUE);

// WRITE THE PDF TO DISK
$pdf->Output($pdf_file_name,'F');

// PRESENT A LINK
echo "<a target=\"my_PDF\" href=\"$pdf_file_link\">PDF</a>\n";

Open in new window

0
 
LVL 5

Author Comment

by:vivekpv10
ID: 35147793
Ok Ray...i will test it...
0
 
LVL 5

Author Closing Comment

by:vivekpv10
ID: 35231885
Thanks....
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

825 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