PDF Real-Time Generation  
Note

- No external PDF library required. FPDF 1.53 is included in the REALTOR 747 script.
- Supported image types: JPEG, PNG
- Supported languanges: Excerpt from FPDF website.
What languages can I use?

The class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set. Chinese, Japanese and Korean are supported too.
- PDF template customization is beyond the scope of free technical support.

1. FPDF - Free PDF

REALTOR 747 script uses FPDF Version 1.53. No external PDF library is required because FPDF 1.53 is embedded in the REALTOR 747 script.
Excerpt from FPDF Website:

FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.
FPDF website has good manuals, tutorials, FAQ page and support forum which should be enough for you to develop your own PDF template or to customize the free PDF templates we provide for REALTOR 747.

FPDF Website: http://www.fpdf.org/

2. Sample PDF Templates

The following screen shots are from the PDF templates we provide for free.

Template: PDF_default
Live Demo
Template: PDF_400
Live Demo
Template: PDF_420
Live Demo
Template: PDF_440
Live Demo

As you may notice, the property listings shown in the shots are the same. Depending on the layout (template), the listing looks different. You can generate that kind of PDF files in real time with REALTOR 747.

To see all available free PDF templates, go to our Download PDF Templates Page.

3. Using PDF Generation for your site visitors

With no doubts, this real-time PDF generation will give your site visitors an impression that you are a professional real estate agent.



1. Enable the PDF Genarator
--- [Admin] - [Setup] - [PDF Generator] - Make it 'Enable'

2. Select a PDF Template for Visitors
--- [Admin] - [Setup] - [PDF Generator] - [PDF Template - User] - Select a template

3. Use the generator in your html user template file.
--- $ll[ 'pdf_link' ] - PDF generator for each listing - listings.html search.html
--- $l_pdf_link - PDF generator for the specified listing - detail.html
--- $sp_pdf_link - PDF generator for the featured (special) listing - any html file

For example, if you want to provide a link to the PDF generator in detail.html file,
in detail.html
<a href="{/ $l_pdf_link /}" target="_blank">PDF</a>

For more example, please see realtor747/user/templates/white2 template files. They are included in the product (and in the trial version).

4. Using PDF Generation for admin (agents)

You can have as many PDF templates as you need.



For example, you can have a template good to produce a flyer for houses, another one good for businesses and another one for a very high resolution flyer. By having multiple templates, you will be able to choose a specific template depending on your needs at a given time.

You can benefit greatly from this PDF generation when you are:
- presenting a property listing to your potential buyer.
- producing a high quality flyer for mass printing.
- attaching a PDF flyer in an email to your client.
- ...

To generate a PDF for a specific listing:
- [Admin] - [Listings] - Select A Listing - [PDF Generation] - Click [PDF] button for any template you need

5. PDF Templates Tree Structure

realtor747/pdf.phpPDF generator
realtor747/pdfPDF base directory
 
realtor747/pdf/fpdf.phpFPDF class
realtor747/pdf/docFPDF manual
realtor747/pdf/tutorialFPDF tutorials
realtor747/pdf/fontFPDF fonts
 
realtor747/pdf/templatesPDF templates base directory
realtor747/pdf/templates/Template_NameIndividual template directoty
realtor747/pdf/templates/Template_Name/index.phpMain template file
realtor747/pdf/templates/Template_Name/imagesPDF images directory

-- ex. realtor747/pdf/templates/PDF_400
-- ex. realtor747/pdf/templates/PDF_400/index.php
-- ex. realtor747/pdf/templates/PDF_400/images

Hint: Template_Name is the name of the directory. So, rename the directory so that you can easily differentiate one template from another.
-- ex. PDF_house_for_sale, PDF_office_building

6. Very Simple Template Customization

After you download a free PDF template from our site, you can customise it very simply by replacing 2 image files - your logo and background image.

1. Replace Template_Name/images/logo.jpg image with yours.
2. Replace Template_Name/images/background.jpg image with yours.

* The image file name must be the same unless you modify the template source code.
* Please note that image types must be: JPEG or PNG.


7. PDF Template Markers

A marker for a PDF template is just a php variable. So, use the markers as php variables in your PDF template.

For example, to display your business name,

{/ $business_name /} - in your user template file (a html file)
$pdf->Cell( 0, 0, $business_name ); - in your PDF template file (a php file)

Markers available for PDF templates
Global                 - ex. it747_home
Business Information   - ex. business_name
Categories             - ex. cat['name']
Services               - ex. svc['name']
About Information      - ex. about['name']
Featured Listing       - ex. sp_name
Listing Detail         - ex. l_name
- You can find all detailed markers information on page: Template Markers - Current

* There is a special PDF template named 'PDF_Template_Variables'. If you generate a PDF using that template, you will see all available markers and thier values for the specified listing.

8. Writing Your PDF Template

Learning how to write or customize a PDF template can be done in two steps.

Step 1. Learn about FPDF.

Step 2. Use PDF template markers with FPDF.
- The above PDF Template Markers section
- Page: Template Markers - Current

For example, in step 1, you will learn how to write 'Hello World!' into a PDF file.
Hello, World!
<?php
require('fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

In step 2, you are ready to write your 'business name' into a PDF template. Just know the following things.
When writing a PDF template for REALTOR 747:
1. Do not include line: require( 'fpdf.php' );
   - The file has already been included by REALTOR 747.

2. The main file name of your template must be 'index.php'
   - ex. realtor747/pdf/templates/PDF_house/index.php
   - You can include other php file(s) within index.php if necessary.
$business_name: John The Realtor
<?php

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$business_name);
$pdf->Output();
?>

9. FAQ

FPDF website has a good FAQ page which covers most of your questions you may have during the customization/ development of a PDF template. Several questions (which have been answered by the FPDF FAQ page) you may be interested in:

2. When I try to create a PDF, a lot of weird characters show on the screen. Why?
3. I try to generate a PDF and IE displays a blank page. What happens?
6. When I'm on SSL, IE can't open the PDF.
9. I encounter the following error when I try to generate a PDF: Warning: Cannot add header information - headers already sent by (output started at script.php:X)
15. I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?
16. What's the limit of the file sizes I can generate with FPDF?

FPDF Website: http://www.fpdf.org/
FPDF FAQ Page: http://www.fpdf.org/en/FAQ.php

A.1 Sample PDF template file

Here is a complete sample PDF template file 'PDF_default/index.php' which is included in the product. To see the result page, please click here.
Sample. PDF_default/index.php
<?php

/*
 *  Project:    AD747
 *  Author(s):  Frank Oh
 *  Website:    www.it747.com
 *
 *  This is a sample PDF template file based on FPDF 1.53 
for REALTOR 747 script.
 *
 *  To learn how to use FPDF class, please visit FPDF website 
at http://www.fpdf.org/
 *
 */

    // $l_long_desc Maximum # of characters
define( MAX_LONG_DESC,  800 );  
    // $l_features Maximum # of features
define( MAX_FEATURES,   10 );   
    // $l_attrs Maximum # of attributes (additional info)
define( MAX_ATTRS,      10 );   

class PDF extends FPDF
{
    // Page header
    function Header()
    {
        global  $g_template_markers;
        extract( $g_template_markers );

        // Background Image
        $this->Image(  'images/background.jpg', 0, 0 );

        // Logo
        $this->Image(  'images/logo.jpg', 10, 5 );

        // New / Sold
        $s = $l_sold? "SOLD!" : "";
        $s = $l_new? "NEW!" : $s;
        $this->SetXY( 10, 130 );
        $this->SetFont( 'Times', 'BI', 160 );
        $this->SetTextColor( 0xE2, 0xE2, 0xE2 );
        $this->Cell( 0, 50, $s, 0, 1, 'C' );
        $this->SetXY( 10, 40 );
    }

    // Page footer
    function Footer()
    {
        global  $g_template_markers;
        extract( $g_template_markers );

        // Business Info
        $contact = "$business_name Phone: $business_phone 
Fax: $business_fax Email: $business_email";
        $this->SetLeftMargin( 10 );
        $this->SetY( -10 );
        $this->SetFont( 'Arial', 'BI', 10 );
        $this->Cell( 0, 0, $contact, 0, 1, 'C');

        // Link
        $this->SetY( -7 );
        $this->SetFont( 'Arial', 'I', 7 );
        $this->Cell( 150, 4, $l_link, 0, 0, 'L' );
        $this->Cell( 0, 4, "Listing No: $l_id", 0, 0, 'R' );
        $this->Ln();
    }
}


// Page Setup

    $pdf = new PDF( 'P', 'mm', 'Letter' );
    $pdf->SetAuthor( $business_name );
    $pdf->SetTitle( $l_name );
    $pdf->SetSubject( $l_name );
    $pdf->SetAutoPageBreak( true, 10 );
    $pdf->SetMargins( 10, 30 );
    $pdf->SetTextColor( 0, 0, 0 );
    $pdf->AddPage();


// Title

    $pdf->SetXY( 10, 35 );
    $pdf->SetFont( 'Times', 'BI', 18 );
    $pdf->SetTextColor( 0x55, 0x55, 0x55 );
    $pdf->SetTextColor( 0, 0, 0xFF );
    $pdf->Cell( 0, 8, "$l_name - $l_catch_phrase", 0, 0, 'C' );
    $pdf->SetTextColor( 0, 0, 0 );
    $pdf->Ln();


// Images
    $ymark_1 = 44;
    $ymark_2 = 76;
    $ymark_3 = 92;

    $image = $l_images[1];
    $link = $image? $image[ 'link' ] : 'images/spacer_pic.jpg';
    $pdf->Image( $link, 10, $ymark_1, 44, 33 );

    $image = $l_images[2];
    $link = $image? $image[ 'link' ] : 'images/spacer_pic.jpg';
    $pdf->Image( $link, 160, $ymark_1, 44, 33 );

    $image = $l_images[3];
    $link = $image? $image[ 'link' ] : 'images/spacer_pic.jpg';
    $pdf->Image( $link, 10, $ymark_3, 44, 33 );

    $image = $l_images[4];
    $link = $image? $image[ 'link' ] : 'images/spacer_pic.jpg';
    $pdf->Image( $link, 160, $ymark_3, 44, 33 );

    $image = $l_images[0];
    $link = $image? $image[ 'link' ] : 'images/spacer_pic.jpg';
    $pdf->Image( $link, 53, $ymark_1, 108, 81 );


// New/Sold & Price

    $pdf->SetXY( 10, $ymark_2 );
    $pdf->SetFont( 'Times', 'BI', 30 );
    $pdf->SetTextColor( 0xFF, 0, 0);

    $s = $l_sold? "SOLD!" : "";
    $s = $l_new? "NEW!" : $s;
    $pdf->Cell( 50, 20, " $s", 0, 0, 'L' );
    $pdf->Cell( 0, 20, "$l_price ", 0, 1, 'R' );

    $pdf->SetLeftMargin( 10 ); $pdf->Ln();
    $pdf->SetY( 130 );


// Property Details

    $pdf->SetFont( 'Times', 'BI', 18 );
    $pdf->SetTextColor( 0, 0, 0xFF );
    $pdf->MultiCell( 0, 8, "Property Details", 'B', 'L' );
    $pdf->SetTextColor( 0, 0, 0 );

    $pdf->Cell( 0, $h=3, '', 0, 1 );   // spacer


// Address

    $pdf->SetFont( 'Arial', '', 10 );
    $pdf->Cell( 0, 0, "$l_address ( $l_area )", 0, 1, 'L' );

    $pdf->Cell( 0, $h=3, '', 0, 1 );   // spacer


// Property Description

    $pdf->SetFont( 'Times', 'B', 12 );
    $pdf->Cell( 0, 7, "Property Description", 0, 1, 'L' );

    $long_desc = str_replace( "\n", " ", $l_long_desc );
    $long_desc = substr( $long_desc, 0, MAX_LONG_DESC );
    if ( strlen( $long_desc ) >= MAX_LONG_DESC ) $long_desc .= " ...";

    $pdf->SetFont( 'Arial', '', 10 );
    $pdf->MultiCell( 0, 4, $long_desc );

    $pdf->Cell( 0, $h=3, '', 0, 1 );   // spacer


// Features

    $pdf->SetFont( 'Times', 'B', 12 );
    $pdf->Cell( 0, 8, "Property Features", 0, 1, 'L' );

    $s = '';
    $l_features = array_slice( $l_features, 0, MAX_FEATURES );
    foreach( $l_features as $l_feature ) {
        $s .= "* " . $l_feature[ 'name' ] . "  ";
    }
    $pdf->SetFont( 'Arial', 'I', 10 );
    $pdf->MultiCell( 0, 4, "   $s" );

    $pdf->Cell( 0, $h=3, '', 0, 1 );   // spacer


// Additional Information

    $ymark_add_info = $pdf->GetY();

    $pdf->SetFont( 'Times', 'B', 12 );
    $pdf->Cell( 0, 7, "Additional Information", 0, 1, 'L' );

    $l_attrs = array_slice( $l_attrs, 0, MAX_ATTRS );
    $pdf->SetFont( 'Arial', '', 10 );
    foreach( $l_attrs as $l_attr ) {
        $pdf->Cell( 0, 4, "   + " . $l_attr[ 'name' ] . " :  " 
. $l_attr[ 'value' ], 0, 1, 'L' );
    }


// Agent Info

    $pdf->SetLeftMargin( 90 ); $pdf->Ln();
    $pdf->SetY( $ymark_add_info );

    $pdf->SetFont( 'Times', 'BI', 18 );
    $pdf->SetTextColor( 0, 0, 0xFF );
    $pdf->MultiCell( 0, 8, "Contact Information", 'B', 'L' );
    $pdf->SetTextColor( 0, 0, 0 );

    $pdf->Cell( 0, $h=5, '', 0, 1 );   // spacer

    $pdf->Image( $l_agent[ 'image' ], 90, $pdf->GetY(), 25 );

    $pdf->SetLeftMargin( 120 );

    $pdf->SetFont( 'Arial', 'BI', 12 );
    $pdf->Cell( 0, 4, $l_agent[ 'name' ] . " ( " . 
$l_agent[ 'job_title' ] . " )", 0, 1 );
    $pdf->Ln();

    $pdf->SetFont( 'Arial', '', 10 );
    $pdf->Cell( 15, 4, "Phone:" );
    $pdf->Cell( 0, 4, $l_agent[ 'phone' ], 0, 1 );

    $pdf->Cell( 15, 4, "Mobile:" );
    $pdf->Cell( 0, 4, $l_agent[ 'cellphone' ], 0, 1 );

    $pdf->Cell( 15, 4, "Fax:" );
    $pdf->Cell( 0, 4, $l_agent[ 'fax' ], 0, 1 );

    $pdf->Ln();
    $pdf->Cell( 15, 4, "Email:" );
    $pdf->Cell( 0, 4, $l_agent[ 'email' ], 0, 1 );

    $pdf->Cell( 15, 4, "Website:" );
    $pdf->Cell( 0, 4, $l_agent[ 'html_page' ], 0, 1 );

    $pdf->Cell( 0, $h=2, '', 0, 1 );   // spacer


// Disclaimer

    $pdf->SetLeftMargin( 90 ); $pdf->Ln();
    $disclaimer = "All information is deemed reliable but is not guaranteed 
and should be independently verified.";
    $pdf->SetFont( 'Arial', 'I', 8 );
    $pdf->MultiCell( 0, 4, "$disclaimer", 1, 'C');


// Output

    $pdf->SetDisplayMode( 100 );
    $pdf->Output( "listing_$l_id.pdf", "I" );


/* vim: set expandtab sw=4 ts=4 sts=4: */
?>



Copyright © 2003-2010 IT747.COM