PHP Classes
elePHPant
Icontem

PHP Reports: Generate PDF and DOCX reports from Word templates

Recommend this page to a friend!
  Info   View files View files (1)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-01-07 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 766 This week: 4All time: 4,322 This week: 104Up
Version License PHP version Categories
php-reports 1.0.2Free for non-comm...5.3.0PHP 5, Web services, Templates
Description Author

This class can generate PDF and DOCX reports from Word templates.

It can send HTTP requests to the PHP Reports API to generate report documents in PDF or DOCX files from templates defined in the Microsoft Word format DOCX.

The class can take the identifier of the template document to use, template variables to replace in the template, and serves the generated report document for download.

Recommendations

Convert Microsoft Word doc, docx to PDF
I want to convert doc file to a PDF file

Convert Word document to PDF
How do I convert a Microsoft Word document to PDF

What is the best PHP docx to pdf class?
View DOCX or PPTX uploaded files in PDF format

What is the best PHP docx to pdf convert class?
Convert the docx or pptx files to pdf files

What is the best PHP class to create PDF table from SQL results
Create query results table in PDF

How to implement a reporting tool or library?
I need to implement a reporting tool or library

Innovation Award
PHP Programming Innovation award nominee
April 2016
Number 13


Prize: One year server license IP to country, region, city, latitude, longitude, ZIP code, time zone, area code database
Many PHP applications need to generate documents that can be printed. Usually they use the PDF format as output.

Generating PDF programmatically is not easy, so it is better to convert from some other format.

This class provides an alternative solution that consists in producing templates in Microsoft Word DOCX format, replace some variable values inside them and then output the final output using a Web service.

The Web service also supports generating the processed templates in DOCX format.

Manuel Lemos
  Performance   Level  
Name: Murat Cileli <contact>
Classes: 2 packages by
Country: Turkey Turkey
Age: ???
All time rank: 251440 in Turkey Turkey
Week rank: 104 Up2 in Turkey Turkey Up
Innovation award
Innovation award
Nominee: 2x

Details

PHP Reports Documentation

PHP-Reports is a cloud based, interactive report engine which helps in generating well formatted PDF reports from Word / DOCX templates in PHP, ASP.NET, ASP.NET MVC, WPF, Silverlight, WinRT, HTML5, Windows Forms, Java, Python, Objective-C, Swift, Delphi and other languages as well.

Read most up-to-date documentation at https://www.php-reports.com/documentation

1. Getting API Key

Create free account at https://www.php-reports.com and get your free API Key.

2. Creating Your First Template

To accelerate the process of creating your reports and applications, PHP Reports takes advantage of Microsoft Word's design capabilites. Simply create a Microsoft Word file and design your report.

3. Using Template Variables

You can use template variables in your Word template. Tamplate variables take their name from the contents of their double curly braces and they can later be replaced with a concrete value.

All template variable names within a template string must be unique. Template variable names are case-insensitive.

Examples of valid template strings:

  • {{client_name}}
  • {{email_address}}
  • {{products}}

4. Upload Your Template

Save and upload your teamplate at "Template Manager" section in https://www.php-reports.com

5. Include PHPReports.php Class to Your Project

Download https://github.com/murat-cileli/php-reports or install via Composer.

composer require murat-cileli/php-reports

6. Generating Reports

You can assign a single value or an array to template variable. Templates variables that have multiple values, will be seperated by linebreaks in your generated report.

$pr = new PHPReports('f9nb3k8bzfumne6g6yu6fu4d');
$pr->setTemplateId(2);
$pr->setOutputFileType(PHPReports::OUTPUT_PDF);
$pr->setOutputAction(PHPReports::ACTION_GET_DOWNLOAD_URL);
$pr->setOutputFileName('My_Generated_Report.pdf');
$pr->setTemplateVariables(
    array(
        'client_name' => 'Armut Inc.',
        'email_address'      => 'murat.cileli@gmail.com',
        'products'     => array('Computer', 'Smart Phone', 'Book')
    ));

Finally, generate your report using single line of code.

$pr->generateReport();
  Files folder image Files  
File Role Description
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:766
This week:4
All time:4,322
This week:104Up