Solved

Generate pdf report in New browser window Drupal

Posted on 2011-03-14
6
690 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 110

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 110

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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