On line guide/help

Navigate sequentially through the guide pages or search for a topic of interest to you

Start Prev. Next

Test installation

To verify that the library is working, you can create a test page with the following PHP code that will display a simple message. This code is a standard index.php page. If you use a framework like Laravel or Symfony you must add the test code in a controller and set the route that call it. Also add the XML template file (see below).


<?php
/*
 * Test url:
 * https://<your_path>/index.php
 *
 */
 
require_once('./vendor/autoload.php');

use AlienProject\PDFReport\PDFReport;

$label = "Hello WORLD";
$templateFileName = getcwd() . DIRECTORY_SEPARATOR . 'hello.xml';
$report = new PDFReport();
$report->LoadTemplate($templateFileName);
$report->SetVar('HELLO_MESSAGE', $label);
$report->BuildReport();

?>

File : index.php

Create an xml file in the root folder with the following code:

<pdf>
	<!-- *** Document info. *** -->
	<info>
		<creator>Alien Project</creator>
		<author>#MBR</author>
		<title>Hello World</title>
	</info>
	<section id="main">
		<page format="A5" orientation="L"/>
		<print_content>hello</print_content>
		<output>
			<dest>F</dest>
			<name>page_sample_01.pdf</name>
			<isUTF8>true</isUTF8>
		</output>
	</section>
	<content id="hello">
		<!-- *** start *** -->
		<box x1="10" y1="60" x2="200" y2="85">
			<text>{HELLO_MESSAGE}</text>
			<textvertalign>Center</textvertalign>
			<texthorizalign>Center</texthorizalign>
			<border>0</border>
			<linewidth>0.25</linewidth>
			<linecolor>000000</linecolor>
			<fill type="S" color="2874a6"/>
			<font>
				<fontfamily>Helvetica</fontfamily>
				<fontsize>32</fontsize>
				<fontstyle>B</fontstyle>
				<fontcolor>FFFFFF</fontcolor>
			</font>
		</box>
		<!-- *** end *** -->
	</content>
</pdf>

File : hello.xml