aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/archive/item.php7
-rw-r--r--views/list/export/index.php39
-rw-r--r--views/list/export/meta.php4
3 files changed, 50 insertions, 0 deletions
diff --git a/views/archive/item.php b/views/archive/item.php
index 467fb2c..25b1719 100644
--- a/views/archive/item.php
+++ b/views/archive/item.php
@@ -7,7 +7,14 @@
</div>
<div class="details">
<span>Visits: <?= $page->Visits ?></span>
+ <iframe id="printFrame" src="<?= '/archives/' . $page->WID . '/index.php' ?>" style="display:none;"></iframe>
<span class="float-right"><?= Database\User::fromDBuid($page->RequesterUID)->Username ?></span>
+ <form action="/list/export/index.php" method="GET">
+ <input type="hidden" name="wid" value="<?= $page->WID ?>">
+ <input type="hidden" name="title" value="<?= $page->Title ?>">
+ <input type="hidden" name="url" value="<?= $page->URL ?>">
+ <button>Export to PDF</button>
+ </form>
</div>
</section>
<section name="itemButton" hidden>
diff --git a/views/list/export/index.php b/views/list/export/index.php
new file mode 100644
index 0000000..6e58405
--- /dev/null
+++ b/views/list/export/index.php
@@ -0,0 +1,39 @@
+<?php
+ namespace Dompdf;
+
+ require_once(__DIR__ . '/../../../libs/dompdf/autoload.inc.php');
+ use Dompdf\Dompdf;
+ use Dompdf\Options;
+
+ try {
+ createWithDOMPDF();
+ }
+ catch (Exception $e) {}
+
+ function createWithDOMPDF() {
+ $url = $_GET['url'];
+ $title = $_GET['title'];
+ $wid = $_GET['wid'];
+ $archive_dir = __DIR__ . '/../../../.archives/' . $wid;
+ $html = file_get_contents($archive_dir . '/index.php');
+
+ $dompdf = new Dompdf();
+ $options = $dompdf->getOptions();
+ $options->setDefaultFont('DejaVu Sans');
+ $options->setIsPhpEnabled(True);
+ $options->setIsJavascriptEnabled(True);
+ $options->setIsRemoteEnabled(True);
+ $options->setChroot($archive_dir . '/../');
+ $options->setIsHtml5ParserEnabled(True);
+ $dompdf->setOptions($options);
+ $dompdf->setBasePath($archive_dir);
+
+ $dompdf->loadHTML($html);
+ $dompdf->setBasePath($archive_dir);
+ $dompdf->setPaper('A4', 'landscape');
+ $dompdf->render();
+ //$dompdf->stream($title . '.pdf', array('Attachment'=>0));
+ // NOTE: Uncomment this to enable the download
+ $dompdf->stream($title . '.pdf');
+ }
+?>
diff --git a/views/list/export/meta.php b/views/list/export/meta.php
new file mode 100644
index 0000000..2546db5
--- /dev/null
+++ b/views/list/export/meta.php
@@ -0,0 +1,4 @@
+<?php
+
+$title = 'Export to PDF';
+$controller = 'list';