PDF layout in JATSParserPlugin

Dear @Vitaliy and others

I have tried the JATSParserPlugin to generate PDF-files on-the-fly from XML. However, I don’t get how I can modify the layout of the PDF:s
Is it some CSS files somewhere?

Can I have different layouts for different journals in a multijournal insallation of OJS?

Hi @eddoff,

PDFs are created with TCPDF library: Examples · TCPDF
I use here HTML to PDF conversion. It supports several CSS attributes: Examples · TCPDF Although it’s probably not a full list, it gives the view that not much is supported. The easiest way would be to catch parsed HTML before it is sent to TCPDF and inject CSS code there. Unfortunately, it can be done only by PHP: php - How to use external css in tcpdf pdf generation - Stack Overflow. HTML for TCPDF is here: https://github.com/Vitaliy-1/JATSParserPlugin/blob/master/JatsParserPlugin.inc.php#L327. So, you’ll need to add a line as per example starting with: $htmlString .= ...
Actually, it’s a good proposal, I’ll consider it’s implementation.

Also, I think it’s possible to write a direct conversion from PHP objects from JATS Parser to TCPDF entities that will give more possibilities for customization (e.g., 2-column layout, another header) but 1) it requires a lot of effort 2) it requires more support.

Dear @Vitaliy,

I have looked at this and made some small modifications in the oldGregg theme. However, I can not find the way to add the DOI-link and publication date to the pdf-file. Is this information available in variables such as $articleArrays and $templateMgr in OldGreggThemePlugin.inc.php, and how can in find out the content of these arrays?

Best regards,


In the next Old Gregg release JATS Parser library will be decoupled from the theme, thus I suggest to work with JATS Parser plugin directly. Note, in near future all themes would be able to show article’s fulltext on the article landing page through JATS Parser, not only Old Gregg.

The method responsible for PDF creation is here: https://github.com/Vitaliy-1/JATSParserPlugin/blob/master/JatsParserPlugin.inc.php#L364
The body is formed from HTML document, so if you want to add anything there you need to inject it in PHP DOM here and it’s called here. The easiest way would probably be passing PublishedArticle object through that method.

If the idea is to inject DOI into header or footer, the best would be check TCPDF documentation.

The latter is the instance of PKPTemplateManager, which in turn is a child of Smarty and inherits all its methods. The former is the instance of PublishedArticle object, I have no idea why I called it that way :slight_smile: Anyway, there is a correspondent annotation. You can look at available methods in this class and it’s parent (Article) and grandparent (Submisison).

Let me know if you stuck on something specific. In general, I’d like to add methods that can make adding custom code and CSS into the TCPDF easier. I’d be grateful for the contribution.

1 Like

Thank you!

I will look into this and try to insert the DOI.
We have tested oldGregg with images in various sizes. JATSparser scale all images in the PDF:s to paper width if they are large enough. However, if they are smaller it looks nice in the pdf and on the website, but the scaling of the image is incorrect in the HTML version when maximizing the image. see for example the second image in the end of this test article:

Thanks for reporting. Yes, I know this bug and it’s something that I plan to change in the new release.
Just want to add that the new version of Old Gregg theme would be much different. I’m making new design for it but the functionality would be much the same, plus there would be new features. E.g., yesterday I finally added the back-end support for most viewed articles. Although it will take some time but I believe the results will worth it.

If you are planning to make changes in the theme (not the JATS Parser Plugin), e.g., creating a child theme, I suggest to wait until new release.

1 Like