You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good Evening. Would it be possible to provide the source code of your site pdf-circus, so that I get better an idea on how to integrate pdfassembler into my nuxt/vue.js site.
Why can't you upload pdf-circus source code (at least the split-join page) to github so I can get a glimpse at your code to get a better idea of how you did it?
For those who want (at least) the merge functionality:
function pdfMerge(urls, divRootId) {
//necessário pois para manter as promisses sincronizadas com await
(async function loop() {
for (url_item of urls) {
console.log("loading: " + url_item);
var loadingTask = pdfjsLib.getDocument(url_item);
//sem isso fica dessincronizado
await loadingTask.promise.then(function (pdf) {
pdf.getMetadata().then(function (metaData) {
console.log("pdf (" + urls + ") version: " + metaData.info.PDFFormatVersion); //versão do pdf
}).catch(function (err) {
console.log('Error getting meta data');
console.log(err);
});
console.log("páginas: " + pdf.numPages);
let i = 0;
while (i < pdf.numPages) {
var pageNumber = i;
pdf.getPage(pageNumber).then(function (page) {
var div = document.createElement("div");
var documentosDiv = document.querySelector('#' + divRootId);
documentosDiv.appendChild(div);
var canvas = document.createElement("canvas");
div.appendChild(canvas);
// Prepare canvas using PDF page dimensions
var viewport = page.getViewport({scale: 1, });
//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
};
var renderTask = page.render(renderContext);
renderTask.promise.then(function () {
console.log('Page rendered');
});
});
i++;
}
// Fetch the first page
}, function (reason) {
// PDF loading error
console.error(reason);
});
}
})();
}
Activity
celsowm commentedon Jul 5, 2019
such a pity there is not a simple example of "how to join pdfs" on pdfassembler :(
Dinibewerbig commentedon Jul 6, 2019
Why can't you upload pdf-circus source code (at least the split-join page) to github so I can get a glimpse at your code to get a better idea of how you did it?
celsowm commentedon Jul 6, 2019
For those who want (at least) the merge functionality:
Dinibewerbig commentedon Jul 6, 2019
Thank you! Very kind. God bless you!
Muito Brigado!
celsowm commentedon Jul 6, 2019
You are welcome @Dinibewerbig !
Do not forget to include pdfjs-dist (.js and .maps) in your project ! It works smooth even without NodeJS !