Javascript: how to use pdfObject to view PDF files

Using the library pdfObject you can view files pdf in their own web pages with very few lines of code. Let's see how.

How to use pdfObject to view PDF files in Javascript

Javascript: how to use pdfObject to view PDF files



PDFObject example


window.onload = function (){
var myPDF = new PDFObject({ url: “sample.pdf” }).embed();
};


It appears you don’t have Adobe Reader or PDF support in this web
browser. Click here to download the PDF



This other example instead shows the two fillet PDF on one page:



<!–

#pdf1, #pdf2 {
width: 500px;
height: 300px;
margin: 2em auto;
border: 10px solid #6699FF;
}

#pdf1 p, #pdf2 p {
padding: 1em;
}

#pdf1 object, #pdf2 object {
display: block;
border: solid 1px #666;
}

->


var pdfOpen_params = {

navpanes: 1,
view: “FitH”,
pagemode: “thumbs”

};

var pdfAttributes = {

url: “/pdf/sample.pdf”,
pdfOpenParams: pdfOpen_params

};

window.onload = function (){

var pdf = new PDFObject(pdfAttributes);
pdf.embed(“pdf1”);

var pdf2 = new PDFObject({ url: “/pdf/sample.pdf” });
pdf2.embed(“pdf2”);


};


Embedding multiple PDFs using PDFObject
Multiple PDFs can be embedded inside a single HTML document. Note that this is not a recommended practice and may result in buggy behavior from Adobe Reader.
 

It appears you don’t have Adobe Reader or PDF support in this web browser. Click here to download the PDF


It appears you don’t have Adobe Reader or PDF support in this web browser. Click here to download the PDF


You can download library and documentation here: http://pdfobject.com/

add a comment of Javascript: how to use pdfObject to view PDF files
Comment sent successfully! We will review it in the next few hours.