-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathexample.php
35 lines (27 loc) · 1.14 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use JATSParser\Body\Document as JATSDocument;
use JATSParser\HTML\Document as HTMLDocument;
use JATSParser\PDF\TCPDFDocument;
/*
* @var $jatsDocument JATSDocument object representation of JATS XML document
*/
$jatsDocument = new JATSDocument("example.xml");
/*
* @var $htmlDocument HTMLDocument conversion to HTML
*/
$htmlDocument = new HTMLDocument($jatsDocument);
//the first parameter is citation style format: https://github.com/citation-style-language/styles
$htmlDocument->setReferences('apa', 'en-US', true);
$htmlDocument->saveAsValidHTMLFile('example.html', 'Arbitrary HTML document title', true);
/*
* @var $pdfDocument TCPDFDocument class that extends TCDPF
*/
$pdfDocument = new TCPDFDocument();
$pdfDocument->AddPage();
$pdfDocument->SetFont('dejavusans');
$htmlString = $htmlDocument->getHtmlForTCPDF();
$pdfHeaderLogo = __DIR__ . "/../logo/logo.jpg";
$pdfDocument->SetHeaderData($pdfHeaderLogo, PDF_HEADER_LOGO_WIDTH, "Some Text Here", "Another text here");
$pdfDocument->writeHTML($htmlString, true, false, true, false, '');
$pdfDocument->Output(__DIR__ . '/example.pdf', 'F');