Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pdfjs = require('pdfjs-dist/build/pdf.js');
const Trie = require('./trie');
const pinyin = require('pinyin');
const MarkdownIt = require('markdown-it');
pdfjs.GlobalWorkerOptions.workerSrc = require.resolve('pdfjs-dist/build/pdf.worker.js');
/* Set scale = -1 to auto-scale */
function renderPDF(content, scale, elem, targetWidth) {
return pdfjs.getDocument(content).then(pdf => {
const promises = [];
for(let i = 1; i <= pdf.numPages; ++i)
promises.push(pdf.getPage(i).then(page => {
let _scale = scale;
if(_scale === -1) {
const svp = page.getViewport(1);
_scale = targetWidth / svp.width;
console.log(_scale);
}
const vp = page.getViewport(_scale);