GithubHelp home page GithubHelp logo

peter279k / uxdm-pdf-destination Goto Github PK

View Code? Open in Web Editor NEW

This project forked from divineomega/uxdm-pdf-destination

0.0 2.0 0.0 10 KB

PDF destination for the UXDM data migrator

License: GNU Lesser General Public License v3.0

PHP 100.00%

uxdm-pdf-destination's Introduction

UXDM PDF Destination

The UXDM PDF destination allows you to migrate data into a PDF table.

Installation

To install the UXDM PDF destination, just run the following composer command.

composer require divineomega/uxdm-pdf-destination

Creating

To create a new PDF destination, you must provide it with the file path of PDF file you wish to export data to. The first row of the PDF table will contain the field names.

The following example creates a PDF destination object, using a PDF file called users.pdf in the same directory.

$pdfFile = __DIR__.'/users.pdf';
$pdfDestination = new PDFDestination($pdfFile);

Custom Paper Size & Orientation

You can alter the PDF destination to output PDFs with a custom paper size and orientation. To do this, use the setPaperSize and setPaperOrientation methods of the PDF destination object, as shown below.

$destination->setPaperSize('A5');
$destination->setPaperOrientation('landscape');

HTML Prefix & Suffix

Internally, the PDF destination renders a basic HTML table into a PDF. If you wish to style the table, add a heading, or extra content, you can add a HTML prefix or HTML suffix.

An example of how to do this is shown below.

$htmlPrefix = '<h1>My Report</h1>
            <style>
                table { width: 100% }
                h1 { text-align: center; }
                th { text-transform: capitalize; text-align: center; } 
                th, td { margin: 0; border: 1px solid #000; }
            </style>';
$htmlSuffix = '<p>Created by UXDM</p>';

$destination->setHtmlPrefix($htmlPrefix);
$destination->setHtmlSuffix($htmlSuffix);

Assigning to migrator

To use the PDF destination as part of a UXDM migration, you must assign it to the migrator. This process is the same for most destinations.

$migrator = new Migrator;
$migrator->setDestination($pdfDestination);

Alternatively, you can add multiple destinations, as shown below. You can also specify the fields you wish to send to each destination by passing an array of field names as the second parameter.

$migrator = new Migrator;
$migrator->addDestination($pdfDestination, ['field1', 'field2']);
$migrator->addDestination($otherDestination, ['field3', 'field2']);

uxdm-pdf-destination's People

Contributors

divineomega avatar

Watchers

Chun-Sheng, Li avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.