- Saved searches
- Use saved searches to filter your results more quickly
- pear/XML_fo2pdf
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.fo2pdf
- PHP API to convert XML to PDF
- Convert a XML file to PDF in PHP
- Code example in PHP using REST API to convert XML to PDF format
- How to use PHP API to convert XML to PDF
- Saved searches
- Use saved searches to filter your results more quickly
- License
- prexview/prexview-php
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
pear/XML_fo2pdf
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.fo2pdf
fo to pdf converter. with fo (formating objects) it's quite easy to convert xml-documents into pdf-docs (and not only pdf, but also ps, pcl, txt and more) An introduction into formating objects can be found at http://www.w3.org/TR/xsl/slice6.html#fo-section http://www.ibiblio.org/xml/books/bible/updates/15.html A tutorial is here: http://www.xml.com/pub/a/2001/01/17/xsl-fo/ http://www.xml.com/pub/a/2001/01/24/xsl-fo/ A html_to_fo.xsl can also be found there http://www.xml.com/2001/01/24/xsl-fo/fop_article.tgz but it didn't work for my simple xhtml files.. The way to use this class is, produce a fo-file from a xml-file with a xsl-stylesheet, then feed this class with this fo-file and you get a pdf back (either directly to the browser for really dynamic-pdf production or as a file on your filesystem) It is recommended to use the Cache-Classes from PEAR, if you want dynamic pdf production, since the process of making the pdfs takes some time. For an example of how to use Cache and fo2pdf see below. Requirements: - You need Fop (version 0.20.1 was used for testing) from the xml-apache project (http://xml.apache.org/fop) and Java (1.1.x or later, i tested it with 1.2.2 from sun on linux, see the Fop-Docs for details). - Furthermore you have to compile your php with --with-java and to adjust your php.ini file. It can be a rather painful task to get java and php to work together. (i also tested this only with jdk 1.2.2, got 1.3.1 to work but not together with sablotron. ) See http://www.phpbuilder.com/columns/marknold20001221.php3 or http://www.linuxwebdevnews.com/articles/php-java-xslt.php?pid=347 or http://www.onlamp.com/pub/a/php/2001/06/14/php_jav.html or http://php.chregu.tv/java-debian.html (some config tips) for more details about java and php. For your reference, my relevant parts in php.ini looks like this: *** extension=libphp_java.so extension.dir=/usr/local/lib/php/20010901/ [java] java.class.path=/usr/local/lib/php/php_java.jar:/usr/local/share/java/fop.jar:/usr/local/share/java/batik.jar:/usr/share/java/xalan-2.0.1.jar:/usr/share/java/xerces.jar:/usr/local/share/java/jimi-1.0.jar java.library=/usr/lib/java/jre/lib/i386/libjava.so *** - If you want to include images or svg-files, then FOP needs an XServer (this is a limitation of the graphics-support in java. See http://www.geocities.com/marcoschmidt.geo/java-image-coding.html for details). Normally webservers don't have Xservers installed, but I made some good experiences with Xfvb. Usage: require_once("XML/fo2pdf.php"); //make a pdf from simple.fo and save the pdf in a tmp-folder $fop = new xml_fo2pdf(); // the following 2 lines are the default settins, so not // necessary here, but you can set it to other values $fop->setRenderer("pdf"); $fop->setContentType("application/pdf"); //If you want other fonts in your PDF, you need to declare them in a // config file. Declare here the path to this file [optional]. // More information about fonts and fop on the apache-fop webpage. $fop->setConfigFile("userconfig.xml"); if (PEAR::isError($error = $fop->run("simple.fo"))) < die("FOP ERROR: ". $error->getMessage()); > //print pdf to the outputbuffer, // including correct Header ("Content-type: application/pdf") $fop->printPDF(); //delete the temporary pdf file $fop->deletePDF(); With Cache: require_once("XML/fo2pdf.php"); require_once("Cache/Output.php"); $container = "file"; $options = array("cache_dir"=>"/tmp/"); $cache = new Cache_Output("$container",$options); $cache_handle = $cache->generateID($REQUEST_URI); if ($content = $cache->start($cache_handle)) < Header("Content-type: application/pdf"); print $content; die(); >$fop = new xml_fo2pdf(); $fop->run("simple.fo"); $fop->printPDF(); $fop->deletePDF(); print $cache->end("+30");
PHP API to convert XML to PDF
Use Cells Conversion REST API to create customized spreadsheet workflows in PHP. This is a professional solution to convert XML to PDF and other document formats online using PHP.
Convert a XML file to PDF in PHP
Converting file formats from XML to PDF is a complex task. All XML to PDF format transitions is performed by our PHP SDK while maintaining the source XML spreadsheet’s main structural and logical content. Our PHP library is a professional solution to convert XML to PDF files online. This Cloud SDK gives PHP developers powerful functionality and perfect PDF output.
Code example in PHP using REST API to convert XML to PDF format
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-php/ php require_once('vendor\autoload.php'); use \Aspose\Cells\Cloud\Api\CellsApi; $instance = new CellsApi(getenv("ProductClientId"),getenv("ProductClientSecret")); $path ='Book1.xml'; $format ='pdf'; $password = null; $outPath = null; $result = $this->instance->cellsWorkbookPutConvertWorkBook($path ,$format, $password, $outPath); $size = $result->getSize(); $content = $result->fread($size); $file = fopen("destfile.pdf", 'w'); fwrite($file,$content); fclose($file);
How to use PHP API to convert XML to PDF
- Create an account at Dashboard to get free API quota & authorization details
- Initialize CellsApi with Client Id, Client Secret, Base URL & API version
- Call cellsWorkbookPutConvertWorkBook method to get the resultant stream
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Transform your data from XML or JSON to high quality, beautiful and readable documents in PDF, HTML, PNG or JPG.
License
prexview/prexview-php
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A composer library to use PrexView, a fast, scalable and friendly service for programatic HTML, PDF, PNG or JPG generation using JSON or XML data.
See PrexView for more information about the service.
php composer.phar require prexview/prexview
git clone https://github.com/prexview/prexview-php.git vendor/prexview
You can get an API Key from PrexView
If you can setup enviroment variables
export PXV_API_KEY="YOUR_API_KEY"
If you can’t setup environment variables, create the PrexView object with your API Key as argument
$pxv = new PrexView\PrexView('YOUR_API_KEY');
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/prexview/src/PrexView.php';
To send an XML string use $pxv->sendXML($xml, $options) method, this method will return a Response object on success or thrown an error.
$pxv = new Prexview\Prexview(); $options = new stdClass(); $options->template = 'supported_languages'; $options->output = 'pdf'; $xml = 'English Español Française '; $file = 'test.pdf'; try < $res = $pxv->sendXML($xml, $options); file_put_contents($file, $res->file); echo 'File created: ' . $file; > catch (Exception $e) < die($e->getMessage()); >
To send a JSON string or PHP standard object use $pxv->sendJSON($json, $options) method, this method will return a Response object on success or thrown an error.
$pxv = new Prexview\Prexview(); $options = new stdClass(); $options->template = 'supported_languages'; $options->output = 'pdf'; $json = new StdClass(); $en = new StdClass(); $es = new StdClass(); $fr = new StdClass(); $en->code = 'en'; $en->name = 'English'; $es->code = 'es'; $es->name = 'Español'; $fr->code = 'fr'; $fr->name = 'Française'; $json->languages = [$en, $es, $fr]; $file = 'test.pdf'; try < $res = $pxv->sendJSON($json, $options); file_put_contents($file, $res->file); echo 'File created: ' . $file; > catch (Exception $e) < die($e->getMessage()); >
Property | Type | Description |
---|---|---|
id | string | Transaction ID. |
file | binary | Document created by the service. |
responseTime | int | Response time from service. |
rateLimit | int | Maximum number of calls to the service. |
rateLimitReset | int | Seconds to reset the rate limit. |
rateRemaining | int | Number of remaining call to the service. |
Name | Type | Required | Description |
---|---|---|---|
template | string | Yes | Template’s name to be used to document creation, you can use dynamic values. |
output | string | Yes | Type of document that will be created by PrexView service, it must be html, pdf, png or jpg. |
note | string | No | Custom information to be added to the document’s metadata, it’s limit up to 500 characters and you can use dynamic values. |
format | string | No | Type of data used to the document creation, it must be xml or json, this should be inferred from library methods. |
templateBackup | string | No | Template’s name to use to be used if the option template is not available in the service. |
In template or note options you can use JSON sintax to access data and have dynamic values, for instance having the following JSON data:
Your template or note can use any data attribute or text node, for instance:
Then we will translate that to the following:
And finally the service will try to find the template or note invoice-customer-123 in order to transform the data and generate the document.
About
Transform your data from XML or JSON to high quality, beautiful and readable documents in PDF, HTML, PNG or JPG.