-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,251 additions
and
108 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,11 @@ | |
* @copyright 2023 David Bogner <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
// import 'mod_datalynx/pdf'; | ||
|
||
import * as pdfjsLib from 'mod_datalynx/pdf'; | ||
import pdfjsWorker from 'mod_datalynx/pdf.worker'; | ||
|
||
// import * as pdfjsLib from 'mod_datalynx/pdf'; | ||
// import * as pdfjsWorker from 'mod_datalynx/pdf.worker'; | ||
|
||
// eslint-disable-next-line require-jsdoc | ||
function renderPDFfunction(url, canvasContainer) { | ||
|
||
function renderPage(page) { | ||
|
@@ -36,22 +35,13 @@ function renderPDFfunction(url, canvasContainer) { | |
canvasContext: ctx, | ||
viewport: viewport | ||
}; | ||
// Calculate the scaling factors to fit the container's width and height | ||
var widthScale = canvasContainer.clientWidth / viewport.width; | ||
var heightScale = canvasContainer.clientHeight / viewport.height; | ||
|
||
// Use the minimum scale to ensure that the entire page fits within the container | ||
var scale = Math.min(widthScale, heightScale); | ||
|
||
// Apply the scaling factor | ||
canvas.width = viewport.width * scale; | ||
canvas.height = viewport.height * scale; | ||
var customScale = 1; | ||
var desiredWidth = 595; | ||
var desiredHeight = 841; | ||
|
||
// canvas.height = canvasContainer.clientHeight; | ||
// canvas.width = canvasContainer.clientWidth; | ||
|
||
// canvas.height = 800; | ||
// canvas.width = 1200; | ||
canvas.height = desiredHeight * customScale; | ||
canvas.width = desiredWidth * customScale; | ||
|
||
canvasContainer.appendChild(canvas); | ||
|
||
|
@@ -75,9 +65,15 @@ function renderPDFfunction(url, canvasContainer) { | |
|
||
} | ||
|
||
// eslint-disable-next-line require-jsdoc | ||
/** | ||
* | ||
* @param {*} pdfUrl | ||
* @param {*} canvasContainerId | ||
*/ | ||
export function renderPDF(pdfUrl, canvasContainerId) { | ||
|
||
console.log(pdfUrl, canvasContainerId); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const pdf = M.cfg.wwwroot + '/mod/datalynx/tests/turnen.pdf'; | ||
const container = document.querySelector(`#${canvasContainerId}`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.