Package: pp.server
NoteThis new version 3 of the Produce & Publish server is a complete rewrite
with an incompatible REST API. Version 3 also requires version 3
of thepp.client-pythonbindings.pp.serveris a FastAPI based server implementation and implements the
server side functionality of the Produce & Publish platform.  It is known as
theProduce & Publish Server.The Produce & Publish Server provided web service APIs for converting
HTML/XML + assets to PDF using one of the following external PDF converters:PrinceXML (www.princexml.com, commercial)PDFreactor (www.realobjects.com, commercial)Speedata Publisher (www.speedata.de, open-source, experimental support)WKHTMLTOPDF (www.wkhtmltopdf.org, open-source, experimental support)Vivliostyle Formatter (www.vivliostyle.com, commercial, experimental support)VersaType Formatter (www.trim-marks.com, commercial, experimental support)Antennahouse 7 (www.antennahouse.com, commercial)Weasyprint (free, unsupported)Typeset.sh  (www.typeset.sh, commercial)PagedJS  (www.pagedjs.org, free)In addition there is experimental support for generating EPUB documents
usingCalibre(www.calibre.org, open-source).The web service provides only synchronous operation.RequirementsPython 3.8 or higher, no support for Python 2.xthe external binariesPrinceXML:prince,PDFreactor:pdfreactor.py,Speedata Publisher:spCalibre:ebook-convertWKHTMLTOPDF:wkhtmltopdfVivliostyle:vivliostyle-formatterVersaType :versatype-converterWeasyprint:weasyprintAntennahouse:run.shTypeset.sh:typeset.sh.pharPageJS:pagedjs-climust be in the $PATH. Please refer to the installation documentation
of the individual products.Installationcreate a Python 3  virtual environment using:python3 -m venv pp.serverinstall the Produce & Publish server:bin/pip install pp.serverrun the Produce & Publish server:bin/uvicorn pp.server.server:appor under control ofgunicorn:bin/gunicorn pp.server.server:app -w 2 -k uvicorn.workers.UvicornWorkerFor running the Produce & Publisher server under control of the process managercircus, generate thecircusd.inifile using:bin/pp-server-templatesand start it in background:bin/circusd circusd.ini  --daemonConverter requirementsFor the PDF conversion the related converter binaries or scripts
must be included in the$PATHof your server.princefor PrinceXMLpdfreactorfor PDFreactor 8 or higherwkhtmltopdffor WKHTMLToPDFebook-convertfor Calibrespfor the Speedata Publishervivliostylefor the Vivliostyle formatterversatypefor the Versatype converterweasyprintfor Weasyprintantennahousefor the Antennahousepagedjsfor the PagedJStypesetshfor the Typeset.shAPI documentationAll API methods are available through a REST api
following API URL endpoint:http://host:port/<command>With the default server configuration this translates to:http://localhost:8000/convertREST API Introspectionpp.serveris implemented based on the FastAPI framework for Python.
You can access the REST API  documentation directly throughhttp://localhost:8000/docsEnvironment variablespp.serveruses thevarfolder of the installation directory by default as
temporary folder for conversion data. Set the environment variablePP_SPOOL_DIRECTORYif you need different spool directory instead.If you run PDFreactor 10 or higher under Docker then you must set the environment
variablePP_PDFREACTOR_DOCKER=1in order to generated a properfile:///docs/…URI forpdfreactor.py.PDF conversion APIRemember that all converters use HTML or XML as input for the conversion. All
input data (HTML/XML, images, stylesheets, fonts etc.) must be stored in ZIP
archive. The filename of the contentmustbe namedindex.html.You have toPOSTthe data to thehttp://host:port/convertwith the following parameters:data- the ZIP archive (as base64 encoded string)converter- a string that determines the the PDF
converter to be used (eitherprincexml,pdfreactor,phantomjs,vivliostyle,versatype,
orcalibrefor generating EPUB content)cmd_options- an optional string of command line parameters added
as given to the calls of the externals convertersReturns:The API returns its result as JSON structure with the following key-value
pairs:status- eitherOKorERRORdata- the generated PDF file encoded as base64 encoded byte stringoutput- the conversion transcript (output of the converter run)Introspection API methodsProduce & Publish server version:http://host:port/versionreturns:{“version”: “3.0.0”, “module”: “pp.server”}Installed/available converters:http://host:port/convertersreturns:{“pdfreactor”: true, “phantomjs”: false, “calibre”: true, “prince”: true}Versions of installed converter:http://host:port/converter-versionsreturns:{‘prince’: ‘Version x.y’, ‘pdfreactor: ‘Version a.b.c’, …}Other API methodsCleanup of the queue directory (removes conversion data older than one day)http://host:port/cleanupreturns:{“directories_removed”: 22}Source codehttps://bitbucket.org/ajung/pp.serverBug trackerhttps://bitbucket.org/ajung/pp.server/issuesSupportSupport for Produce & Publish Server is currently only available on a project
basis.Licensepp.serveris published under the GNU Public License V2 (GPL 2).ContactZOPYXHundskapfklinge 33D-72074 Tuebingen, Germanyinfo@zopyx.comwww.zopyx.comwww.produce-and-publish.info3.3.0 (2023/02/07)modernized codebasePython 3.9 or higher is now requiredno features added3.2.0 (2020/05/12)added selftest endpoint3.1.0 (2020/03/20)various minor fixesavailable_converters() now executed in parallel -> speedup3.0.0 (2020/02/14)complete rewrite using FastAPI as REST backendbetter loggingchanged API namesdropped support for PhantomJS and Unoconvbetter error handlingsimplified configuration for further converter support2.1.0 (2020/08/12)support forpagedjs-cliandtypeset.shadded2.0.4 (2019/02/11)minor installation issues withvarfolder gunicorn.logadded optionalPP_PDFREACTOR_DOCKERenvironment support2.0.3 (2019/02/11)minor installation issues withvarfolder gunicorn.logadded optionalPP_SPOOL_DIRECTORYenvironment support2.0.0 (2018/07/14)major cleanupremoved async functionalityswitched from waitress to gunicornswitched from subprocess to easyprocesswebpage displays installed converters and their versionssupport for VersaType converter added1.0.8 (2017/10/23)internal release1.0.7 (2017/08/17)fixed a very old bug in cleanup code1.0.6 (2017/08/08)display available converters during startup1.0.5 (2017/04/06)support for WeasyPrint1.0.3 (2017/02/13)calling princexml with explicit option -o (Prince 11 compatibility)1.0.0 (2017/01/08)first official releaserequires Python 3.5 or higher0.7.13 (2016/08/30)addedcircusdependency in order to provide daemonizing
support out of the box0.7.12 (2016/08/29)fix for PDFreactor 80.7.11 (2016/06/01)updated to Pyramid 1.70.7.7 (2016/01/24)updated support for latest Vivliostyle formatteradded support for Antennahouse Formatter0.7.6 (2015/11/30)support for PDFreactor 80.7.5 (2015/11/18)fixed race condition while creating directories0.7.4 (2015/11/14)support for nested uploaded ZIP files0.7.3 (2015/11/14)support for Vivliostyle Formatter0.7.2 (2015/04/20)mergedhttps://bitbucket.org/ajung/pp.server/pull-request/1/(improper check for wkhtmltopdf)mergedhttps://bitbucket.org/ajung/pp.server/pull-request/2/(fix for async operations)0.7.1 (2015/03/13)unicode fix in runcmd()0.7.0 (2015/02/15)0.6.x was completely badly packagedchanged repo structure0.6.1 (2015/02/02)add /api/converter-versions to webservice API0.6.0 (2015/01/26)dropped Python 2.X support, Python 3.3 or higher
is now a mandatory requirement0.5.5 (2015/01/23)UTF8 handling fix0.5.3 (2014/11/23)support for WKHTMLTOPDF0.5.2 (2014/11/19)support for Speedata Publisher0.5.1 (2014/10/12)improved error handling0.5.0 (2014/10/12)official Python 3.3/3.4 support0.4.7 (25.09.2014)fixed documentation bug0.4.6 (22.08.2014)removed PDFreactor –addlog option0.4.5 (22.08.2014)added supplementary commandline options to pdfreactor commandline call0.4.4 (24.01.2014)minor typos fixed0.4.3 (20.01.2014)implemented automatic queue cleanup after one day0.4.2 (18.01.2014)URL fix in index.pt related to virtual hosting0.4.1 (13.01.2014)show Python version and converters on index.ptauthorization support added0.4.0 (17.10.2013)Python 3.3 supportPyramid 1.5 support0.3.5 (05.10.2013)added ‘cmd_options’ to pdf and unoconv API
methods for specifying arbitary command line parameters
for the external converters0.3.4 (05.10.2013)added ‘cleanup’ API0.3.3 (05.10.2013)added ‘version’ and ‘converter’ API methods0.3.2 (04.10.2013)added support EPUB conversion usingCalibre0.3.1 (03.10.2013)updated documentation0.3.0 (14.07.2013)unoconv conversion now returns a ZIP archive
(e.g. a HTML file + extracted images)0.2.7 (06.07.2013)added support for Phantom.js converter0.2.5 (05.07.2013)better detecting of prince and pdfreactor binaries0.2.2 (05.07.2013)updated the documentationminor cleanup0.2.1 (04.07.2013)re-added poll API0.2.0 (03.07.2013)converted XML-RPC api to REST api0.1.9 (01.07.2013)monkeypatch pyramid_xmlrpc.parse_xmlrpc_request in order
to by-pass its stupid DOS request body check0.1.7 (29.06.2013)more testsfixesupdated documentation0.1.5 (27.06.2013)test for synchronous operationsfixes0.1.0 (24.06.2013)initial release