<?php

// This code adds a basic tcpdf header call to a page.

// First we add standard tcpdf calls for setting page size and
// font, then call AddPage().

// We generally do not need to worry about this block in terms
// of customization, except for the 'set document information'
// block where we can set PDF name, author, and so on.

// We then turn on the output buffer so that all HTML on this page
// can be captured and turned into a PDF.

// REQUIREMENTS
// We must download tcpdf from:
// http://www.tcpdf.org/download.php
// Extract the file, and place into our install directory at:
// rackforms/app/lib/

// LINKS
// http://www.tcpdf.org/docs.php


require_once('../../../app/lib/pdf/tcpdf/config/tcpdf_config.php');
require_once('../../../app/lib/pdf/tcpdf/tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Form Creator');
$pdf->SetTitle('Form Page');
$pdf->SetSubject('Form PDF');
$pdf->SetKeywords(''); // comma delimited list

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins - all values in millimeters per PDF_UNIT
$pdf->SetMargins(PDF_MARGIN_LEFT, 1, PDF_MARGIN_RIGHT); // left, top, right
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// Set image/text scale factor for pixels to user units
// Defaults in config/tcpdf_config.php :: PDF_IMAGE_SCALE_RATIO to 1.25
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);


// ---------------------------------------------------------

// set font
$pdf->SetFont('helvetica', '', 10);

// add a page - we set page size here
$pdf->AddPage('P', 'letter');

// turn on the output buffer, prevents any output, which is required.
@ini_set('output_buffering', 'On');

if(ini_get('output_buffering') == "" || ini_get('output_buffering') == '0' || ini_get('output_buffering') == "Off") {
	$pdf_message = "<div style=\"padding:30px; background-color:#f1f1f1; color:#545454; font-family: Arial; border-radius:4px;\">";
	$pdf_message .= "<h3>PDF creation requires a PHP feature called <strong>Output Buffering</strong>, which is not enabled on this server.</h3>";
	$pdf_message .= "&nbsp;Please check with your hosting provider for instructions on how to enable.<br/><br/>";
	$pdf_message .= "Typical values will be <strong>1</strong> or <strong>On</strong>.";
	$pdf_message .= "</div>";						
	die($pdf_message);
}
ob_start();
	
// PDF Rendering Flags.
$PAGE_IS_PDF = true;
$PDF_LIBRARY = "TCPDF";

?>