For an intranet application, in which very confidential documents are transferred AES256-encrypted, pdf data sources are available as base64-strings (given the fact they are decrypted first). For testing purposes I read a pdf from server http://ddlab.de/stackoverflow/pdf.js/1/test.pdf
Here´s index.html: http://ddlab.de/stackoverflow/pdf.js/1/index.html
In viewer.js I can set
var DEFAULT_URL = 'test.pdf'; // giving a local or crossdomain path to pdf
My idea is, to set a base64 string as default source like
var DEFAULT_URL = 'data:application/pdf;base64,JVBERi0...GCg=='; // shortened
(which also works in FF)
For this I wrote a small php script, that delivers the base64 encoded string. http://ddlab.de/stackoverflow/pdf.js/1/readfile.php
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ob_start('ob_gzhandler');
header('Content-Type: text/javascript; charset=utf-8');
$file = 'test.pdf';
$mime = mime_content_type ($file);
$data = base64_encode(file_get_contents($file));
$url = 'data:' . $mime . ';base64,' . $data;
echo '/*read pdf and output the base64 code*/' . "\n\n";
echo 'var pdf_src = "' . $url . '";';
ob_end_flush();
?>
This is added to HEAD as
<script type="text/javascript" src="readfile.php"></script>
So, finally I can use
var DEFAULT_URL = pdf_src; // retrieving the base64-string as URL
in viewer.js
This works totally great in FF, but in Safari and Chrome ? Nope.
Can somebody help me with this issue ?