Get_started_corner2
Logo2

iPaper Javascript Viewer API

To embed iPaper docs on your website, you insert a snippet of HTML into your webpage code. If you want a default iPaper, you can just copy/paste the HTML given by Scribd or the API. But iPaper also has a full Javascript API which you can use to customize your iPaper. Below is an example that shows how to use the Javascript API.

<script type="text/javascript" src='http://www.scribd.com/javascripts/view.js'></script> 
<!-- The contents of this div will get replaced with the iPaper -->
  <div id='embedded_flash' > 
    <a href='http://www.scribd.com'>Scribd</a>
  </div>

<script type="text/javascript">
  var scribd_doc = scribd.Document.getDoc(2659, 'key-6vhdaqehjkeob'); 
  scribd_doc.write('embedded_flash');  
</script>

Below is a specification of the scribd.Document class, which you use to create and customize iPaper documents.

Constructors

scribd.Document.getDoc ( document_id , access_key )
This constructor gets an existing iPaper document. You'll need the document_id and access_key to embed the document. You can get these from the Scribd API if you're using it or from the doc's page on Scribd.
scribd.Document.getDocFromUrl ( url , scribd_publisher_id )
This constructor creates an iPaper from the URL of a document. To get the required scribd_publisher_id, you'll need to create a Scribd API account. The URL needs to be a document type supported by Scribd, like a PDF, not a normal HTML webpage.

Public instance methods

write ( element_id )
This method actually embeds the iPaper. It replaces the contents of the element that has ID element_id with the iPaper. For cross-browser compatibility, we recommend using a DIV tag or other block-level element with this method.
addParam ( key , value )
This is a general-purpose method which allows you to add parameters that customize the behavior of iPaper. See the parameter section below for the possible parameters.

Parameters

These are the keys that can be passed to the addParam instance method.

height => integer
The height of the iPaper, in pixels. If this is not sepecified, iPaper will attempt to size itself correctly for the webpage it's embedded in.
width => integer
The width of the iPaper, in pixels. If this is not sepecified, iPaper will attempt to size itself correctly for the webpage it's embedded in.
public => boolean
Whether to make the document public on Scribd. This parameter is only for iPapers created with the getDocFromUrl constructor. With iPapers created with the getDoc constructor it will have no effect.
page => integer
You can use this to scroll the iPaper to a default start page. It defaults to the first page.
mode => string
The iPaper view mode that should be chosen by default. Can be 'list' (the default), 'book' (two-page spread), 'slideshow' (the default for presentations), or 'tile'.
my_user_id => string
If you run a user-generated content site, you can use this parameter to very easily integrate your user authentication system into Scribd. For a full explanation of how this works, please see the Scribd API documentation.
extension => string
This parameter is only for iPapers created from the getDocFromUrl constructor.

When Scribd processes a file it will try to identify the filetype using the contents of the file and various heuristics. If Scribd is guessing wrong on one of your files, you can override this behavior and set the extension directly with this parameter (e.g., "docx").
title => string
This parameter is only for iPapers created from the getDocFromUrl constructor.

Sets the title of the new file uploaded.
transferCookie => boolean
This parameter is only for iPapers created from the getDocFromUrl constructor.

If your documents are stored at URLs that are not accessible on the public internet, you can use this parameter to allow iPaper to read them. If transferCookie is true, iPaper will access the given URL using the browser cookies of the user who is using the iPaper at that moment. This will allow iPaper to bypass cookie-based authentication mechanisms. It should not otherwise be used as it will cause a performance impact.

Example

Here's another example of an iPaper embed with more options set.

<script type="text/javascript" src='http://www.scribd.com/javascripts/view.js'></script> 
  <div id='embedded_flash' > 
    <a href='http://www.scribd.com'>Scribd</a>
  </div>

<script type="text/javascript">
  var scribd_doc = scribd.Document.getDocFromUrl('http://lib.store.yahoo.net/lib/paulgraham/onlisp.ps', 'PUT-YOUR-SCRIBD-PUBLISHER-ID-HERE'); 
  scribd_doc.addParam('height', 600);
  scribd_doc.addParam('width', 400);
  scribd_doc.addParam('page', 10);
  scribd_doc.addParam('public', true);
  scribd_doc.write('embedded_flash');  
</script>

Search engines

If you're using iPaper on you website, you may well want to have the full text of your documents indexed by search engines. Having the full text indexed can be quite effective at bringing additional traffic to your site. To get the text of an iPaper indexed, you use an alternate embed code, one which contains the full text in the embed code itself. It looks like this:
<script type="text/javascript" src='http://www.scribd.com/javascripts/view.js'></script> 
  <div style='display:none' >
   [INSERT THE FULL TEXT HERE: blah blah blah ...]
  </div>

  <div id='embedded_flash' > 
    <a href='http://www.scribd.com'>Scribd</a>
  </div>

<script type="text/javascript">
  var scribd_doc = scribd.Document.getDoc(2659, 'key-6vhdaqehjkeob'); 
  scribd_doc.write('embedded_flash');  
</script>
To get the full text of the documents, we recommend downloading Scribd's extracted text using the docs.getDownloadUrl API method and storing it in a database.