I am trying to implement PDF viewer when should PDF from url display in same application. i use inappbrowser,pdf.js,MUPDF but none of them are working. Can anyone help me to fix this out?
Asked
Active
Viewed 495 times
2 Answers
0
I don't know why you said "none of them are working" because all of them work fine for me. Maybe you should post more details so that we can help you.
This post How to Display PDF File with in the same App in phonegap is similar to your question. Maybe it will help you.
0
The problems is that old webkit versions don't render HTML5 correctly.
The official PDF.js has some features unavailable for devices such as Android 2.3.4 and Iphone 6.1 (old webkit versions).
If you still need help, you can check out my custom PDF.js. I made my changes to fit Android SDK 10 and above.
https://github.com/camilacanhete/PDFJSPhonegap
You can start with some HTML like this:
<div id="wrapper">
<canvas id="the-canvas"></canvas>
<div>
And this in your Javascript:
var pdfDoc = null;
var canvas = $('#the-canvas')[0];
var ctx = canvas.getContext('2d');
var pageRendering = false;
function renderCurrentPage(num) {
pageRendering = true;
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewpt = page.getViewport(scale);
canvas.height = viewpt.height;
canvas.width = viewpt.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewpt
}
var renderTask = page.render(renderContext);
// Wait for rendering to finish
renderTask.promise.then(function () {
pageRendering = false;
});
});
}
PDFJS.getDocument("your-document.pdf").then(function (pdfDoc_) {
pdfDoc = pdfDoc_;
// Initial/first page rendering
renderCurrentPage(pageNum);
});

lucasarruda
- 1,462
- 1
- 25
- 45

Camila S.
- 9
- 1