1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Replace *most* cases of var with let/const in the examples/ folder

These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
This commit is contained in:
Jonas Jenwald 2021-03-12 17:08:17 +01:00
parent 56fd01bf8d
commit 276fa4ad8f
15 changed files with 196 additions and 194 deletions

View file

@ -13,17 +13,17 @@
* limitations under the License.
*/
var PDF_PATH = "../../web/compressed.tracemonkey-pldi-09.pdf";
var PAGE_NUMBER = 1;
var PAGE_SCALE = 1.5;
var SVG_NS = "http://www.w3.org/2000/svg";
const PDF_PATH = "../../web/compressed.tracemonkey-pldi-09.pdf";
const PAGE_NUMBER = 1;
const PAGE_SCALE = 1.5;
const SVG_NS = "http://www.w3.org/2000/svg";
pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.js";
function buildSVG(viewport, textContent) {
// Building SVG with size of the viewport (for simplicity)
var svg = document.createElementNS(SVG_NS, "svg:svg");
const svg = document.createElementNS(SVG_NS, "svg:svg");
svg.setAttribute("width", viewport.width + "px");
svg.setAttribute("height", viewport.height + "px");
// items are transformed to have 1px font size
@ -33,13 +33,13 @@ function buildSVG(viewport, textContent) {
textContent.items.forEach(function (textItem) {
// we have to take in account viewport transform, which includes scale,
// rotation and Y-axis flip, and not forgetting to flip text.
var tx = pdfjsLib.Util.transform(
const tx = pdfjsLib.Util.transform(
pdfjsLib.Util.transform(viewport.transform, textItem.transform),
[1, 0, 0, -1, 0, 0]
);
var style = textContent.styles[textItem.fontName];
const style = textContent.styles[textItem.fontName];
// adding text element
var text = document.createElementNS(SVG_NS, "svg:text");
const text = document.createElementNS(SVG_NS, "svg:text");
text.setAttribute("transform", "matrix(" + tx.join(" ") + ")");
text.setAttribute("font-family", style.fontFamily);
text.textContent = textItem.str;
@ -50,13 +50,13 @@ function buildSVG(viewport, textContent) {
function pageLoaded() {
// Loading document and page text content
var loadingTask = pdfjsLib.getDocument({ url: PDF_PATH });
const loadingTask = pdfjsLib.getDocument({ url: PDF_PATH });
loadingTask.promise.then(function (pdfDocument) {
pdfDocument.getPage(PAGE_NUMBER).then(function (page) {
var viewport = page.getViewport({ scale: PAGE_SCALE });
const viewport = page.getViewport({ scale: PAGE_SCALE });
page.getTextContent().then(function (textContent) {
// building SVG and adding that to the DOM
var svg = buildSVG(viewport, textContent);
const svg = buildSVG(viewport, textContent);
document.getElementById("pageContainer").appendChild(svg);
});
});