mirror of
https://github.com/pierre42100/comunic
synced 2025-10-19 20:34:48 +00:00
First commit
This commit is contained in:
16
3rdparty/pdf.js/examples/helloworld/README.md
vendored
Executable file
16
3rdparty/pdf.js/examples/helloworld/README.md
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
## Overview
|
||||
|
||||
The "hello world" example is a minimalistic application of the PDF.js project.
|
||||
The file `helloworld.pdf` originates from the GNUpdf project and contains a
|
||||
simple and human-readable PDF.
|
||||
|
||||
## Getting started
|
||||
|
||||
Instead of simply opening `index.html` in a browser, you must serve the page
|
||||
using a web server. This can be done on your local machine without an internet
|
||||
connection. In the root directory of PDF.js, run `node make server` in a
|
||||
terminal. The example can then be viewed using the following URL:
|
||||
|
||||
`http://localhost:8888/examples/helloworld/index.html`
|
||||
|
||||
Take a look at `hello.js` to see how to make basic calls to PDF.js.
|
36
3rdparty/pdf.js/examples/helloworld/hello.js
vendored
Executable file
36
3rdparty/pdf.js/examples/helloworld/hello.js
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
//
|
||||
// See README for overview
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Fetch the PDF document from the URL using promises
|
||||
//
|
||||
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
|
||||
// Using promise to fetch the page
|
||||
pdf.getPage(1).then(function(page) {
|
||||
var scale = 1.5;
|
||||
var viewport = page.getViewport(scale);
|
||||
|
||||
//
|
||||
// Prepare canvas using PDF page dimensions
|
||||
//
|
||||
var canvas = document.getElementById('the-canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
//
|
||||
// Render PDF page into canvas context
|
||||
//
|
||||
var renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
};
|
||||
page.render(renderContext);
|
||||
});
|
||||
});
|
68
3rdparty/pdf.js/examples/helloworld/helloworld.pdf
vendored
Executable file
68
3rdparty/pdf.js/examples/helloworld/helloworld.pdf
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
%PDF-1.7
|
||||
|
||||
1 0 obj % entry point
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Pages 2 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/MediaBox [ 0 0 200 200 ]
|
||||
/Count 1
|
||||
/Kids [ 3 0 R ]
|
||||
>>
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 2 0 R
|
||||
/Resources <<
|
||||
/Font <<
|
||||
/F1 4 0 R
|
||||
>>
|
||||
>>
|
||||
/Contents 5 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/BaseFont /Times-Roman
|
||||
>>
|
||||
endobj
|
||||
|
||||
5 0 obj % page content
|
||||
<<
|
||||
/Length 44
|
||||
>>
|
||||
stream
|
||||
BT
|
||||
70 50 TD
|
||||
/F1 12 Tf
|
||||
(Hello, world!) Tj
|
||||
ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 6
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000000079 00000 n
|
||||
0000000173 00000 n
|
||||
0000000301 00000 n
|
||||
0000000380 00000 n
|
||||
trailer
|
||||
<<
|
||||
/Size 6
|
||||
/Root 1 0 R
|
||||
>>
|
||||
startxref
|
||||
492
|
||||
%%EOF
|
29
3rdparty/pdf.js/examples/helloworld/index.html
vendored
Executable file
29
3rdparty/pdf.js/examples/helloworld/index.html
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!-- In production, only one script (pdf.js) is necessary -->
|
||||
<!-- In production, change the content of PDFJS.workerSrc below -->
|
||||
<script src="../../src/shared/util.js"></script>
|
||||
<script src="../../src/display/api.js"></script>
|
||||
<script src="../../src/display/metadata.js"></script>
|
||||
<script src="../../src/display/canvas.js"></script>
|
||||
<script src="../../src/display/webgl.js"></script>
|
||||
<script src="../../src/display/pattern_helper.js"></script>
|
||||
<script src="../../src/display/font_loader.js"></script>
|
||||
<script src="../../src/display/annotation_helper.js"></script>
|
||||
|
||||
<script>
|
||||
// Specify the main script used to create a new PDF.JS web worker.
|
||||
// In production, leave this undefined or change it to point to the
|
||||
// combined `pdf.worker.js` file.
|
||||
PDFJS.workerSrc = '../../src/worker_loader.js';
|
||||
</script>
|
||||
<script src="hello.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<canvas id="the-canvas" style="border:1px solid black;"/>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user