blob: 81070302aa737e4eb6ab54cb03167c7f623cf7f7 (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# Embedded PDF Viewer based on pdf.js
This directory contains an official pdf.js release version, distributed at: https://github.com/mozilla/pdf.js
## Update process
Grab a new official release (*-dist.zip) distributed at github and extract everything except viewer.[html/js/css] and map files into this directory.
Then recreate the resource xml file with `python ./pdfjs_generate_resource.py`
The additional files within this directory are modified for Epiphany and shouldn't be changed automatically.
## Modifications to viewer.html
1. In order to circumvent CORS the pdf is downloaded and then embedded into the viewer.html file. Therefore the head has an
extra attribute 'pdf_data="%s' which will be replace by Epiphany. Extracting this data is done in viewer.js.
2. Futhermore 'pdf_name="%s"' is supplied to set the download file name.
3. '<base href="ephy-resource:///org/gnome/epiphany/pdfjs/web/">' has been added to the head section.
## Modifications to viewer.js
function webViewerInitialized() has been changed:
1. Set file to ''
2. Replace the end of the function with:
var file_name = document.head.getAttribute('pdf_name')
var raw = atob(document.head.getAttribute('pdf_data'));
var raw_length = raw.length;
var array = new Uint8Array(new ArrayBuffer(raw_length));
for(var i = 0; i < raw_length; i++) {
array[i] = raw.charCodeAt(i);
}
try {
PDFViewerApplication.open(array);
PDFViewerApplication.setTitleUsingUrl(file_name);
} catch (reason) {
PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
PDFViewerApplication.error(msg, reason);
});
}
3. Disable history modification, otherwise base url is set as main url and translation won't work.
In _pushOrReplaceState early return before the window.history.xxx changes
4. Hide secondaryViewBookmark and viewBookmark
Switch id's secondaryViewBookmark and viewBookmark from visibleSmallView and hiddenSmallView to hidden.
## Modifications to viewer.css
Here are two small changes for webkit specific layout:
1. Adding:
-webkit-appearance: none; to .dropdownToolbarButton > select {
2. Adding:
.toolbarField.pageNumber { blocks in the css
## Patch with changes for Epiphany
For easier updating to a newer version there is a patch file `epiphany-pdfjs-changes.patch` containing the necessary changes to the viewer files.
## Note
Do not add map files to this bundle (webinspector will complain about it), but they are not needed here and would increase our storage size otherwise.
# Documentation created by Jan-Michael Brummer <jan.brummer@tabos.org>
|