Reputation:
this is PDF.js site
https://github.com/mozilla/pdf.js
I m searching and reading a lot of article, most all the coding are import the pdf into pdf.js
and display on browser, i cannot understand is it PDF.js able to create pdf format and display on web browser without download the PDF file?
this is the sample code i have found :
'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);
});
});
if PDF.js able to create pdf file , and get the data from MySQL database generate a table display on PDF, how is it work?
Upvotes: 5
Views: 6523
Reputation: 508
PDF.JS is only a viewer for PDF documents but you can try jsPDF to do this which is also a open source javascript library
Upvotes: 4