Need to convert jats xml to html and pdf

Hi Vitaliy,

I want to use below plugin without using OJS 3 Framework.

I am trying to use since more than the week still I am on the same page there is no progress at all.

Kindly requesting you. Can you please explain how can I use this plugin without any dependency.

My requirements are:

  1. We need to convert JATS XML to .HTML and .PDF
  2. Converted HTML and PDF must be used JATSPreviewStylesheets

I am waiting for your valuable response.

Also, I want to know the alternate solution for the same.

Rajesh Kumar

Hi @rajesh.k

That plugin isn’t using JATS Preview stylesheets. It transforms JATS XML to XML and PDF on the fly - they are only displayed on the front-end. The usage is simple, to upload JATS XML to the Galleys (Production Stage) and publish it. For HTML transformation it uses own library, in short, the data are transformed to plain PHP objects and then to PHP DOM. As for PDF transformation, it is based on TCPDF library.
The plugin doesn’t upload generated files as a galleys, it only displays them. I’ve done in deliberately to emphasize that they are just copies of original JATS XML.

If you experience problems, I’m happy to help. Can you describe the problem in more details? What is your current OJS 3 version? When you clicking on XML galley from the user side, is file being displayed or the system simple uploads it? Are there any relevant information in PHP logs?


I am some confuse. Can you please tell me about the JATSParserPlugin(GitHub - Vitaliy-1/JATSParserPlugin: OJS3 Plugin for parsing JATS XML and displaying it on article detail page). How can use the features of this plugin without OJS:

  • JATS XML to HTML automatic conversion.
  • JATS XML to PDF automatic conversion.

These feature i can use without OJS. Is it possible?


The library is here: GitHub - Vitaliy-1/JATSParser: JATSParser is aimed to be integrated with Open Journal Systems 3.0+ for transforming JATS XML to various formats
For apps other than OJS, you need to integrated it to your code by yourself. Also, it can be used locally with php-cli. I’ve put example.php file for developers to show how to use this library:
So, this will require some programming skills.

While converting other xml it’s showing error TCPDF ERROR: Wrong page number on setPage() function: 0.

By default it’s showing notices for every compilation-

PHP Notice: Undefined offset: 0 in /home/rajesh/Desktop/JATS/JATSParser-master/vendor/tecnickcom/tcpdf/tcpdf.php on line 17529
PHP Notice: Undefined offset: 0 in /home/rajesh/Desktop/JATS/JATSParser-master/vendor/tecnickcom/tcpdf/tcpdf.php on line 17982

One more question, Using this plugin it can be generate html with TOC(Nav) or not.

Can you share some sample code to save html with generic style sheet.?

Hi @rajesh.k

That error comes from TCPDF library and can mean, for example, that the document is empty. Can you send me problematic JATS XML?

TOC is generated automatically on front-end with Javascript. This plugin parses only body tags and references (but not metadata).

The result HTML is saved as a child of PHP DOM Document object. So, to save it as simple HTML you need to apply its methods. This method should probably do the trick: