Languages

Menu
Sites
Language
PDF

The PDF.js library is a great open source tool created by the developers community and supported by Mozilla. It's main purpose is to display PDF files. You can display files on the canvas or use a sample viewer that converts PDF documents into DOM elements. You can also write your own viewer. In this article, we will show how to create a simple PDF viewer using canvas and PDF.js.

https://developer.tizen.org/documentation/articles/displaying-pdf-files-pdf.js-library

Edited by: John Ixion on 08 Aug, 2015

Responses

3 Replies
John Ixion

In this article, we will show how to create PDF files from scratch. We will use jsPDF library for this purpose. You can download the newest library version just from the GitHub repository or from the official website. Unfortunately, the documentation for the library is poor, so we will describe most important APIs.

https://developer.tizen.org/documentation/articles/creating-pdf-documents-jspdf

asad rehman

i have downloaded the sample application code. i tried to run it, it did not work but then i tried different things in vain. but i was successful to show myself a file which asks me learn

how to make an IDE on Tizen etc etc

my question is how can i make this sample application work.

 

Thanks,

AVSukhov

Hello,

At one time I used pdf.js following way:

    function loadPdf() {
        PDFJS.getDocument('url').then(function (_pdfDoc) {
            pdfDoc = _pdfDoc;
            pdfPages = {
                current : pageNum,
                total : pdfDoc.numPages
            };
            renderPage(pageNum, null);
        });
    }

    function renderPage(num, zoom) {
        pdfDoc.getPage(num).then(function(page) {
            if(!zoom || zoom == defaultScale) {
                var viewport = page.getViewport(window.innerWidth / page.getViewport(1.0).width);
            } else {
                var viewport = page.getViewport(zoom);
            }
            canvas.height = viewport.height;
            canvas.width = viewport.width;
            var renderContext = {
                canvasContext: context,
                viewport: viewport
            };
            page.render(renderContext);
        });
    }

code taken out of context (as it was used Angular.js) but I hope it can helps.