Scribd Javascript API

To embed Scribd documents in your web application, you can use the Javascript API. Using the javascript API, you can both embed documents and connect embeds to custom behavior on your site.

Getting Started

Using Scribd's JavaScript API is easy. To get started, follow these steps:

  • Include Scribd's scribd_api.js
  • Create a Scribd document object with either a doc ID / access key pair (returned by the server-side API) or a URL to a document
  • Pass in an API version (version 2 is the latest one and it will default to HTML5 embeds whenever possible)
  • Call the document object's write method

You can use the following code to create a bare-bones Scribd Reader installation with API support:

<script type="text/javascript" src='http://www.scribd.com/javascripts/scribd_api.js'></script>

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

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

  var onDocReady = function(e){
  // scribd_doc.api.setPage(3);

  scribd_doc.addParam('jsapi_version', 2);
  scribd_doc.addEventListener('docReady', onDocReady);


scribd.Document.getDoc( document_id , access_key )
This constructor gets an existing Scribd Reader 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 a Scribd Reader from the URL of a supported file online. 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.


Only available once Scribd Reader has signaled it's ready. This property is a reference to Scribd Reader's JavaScript interface. View the available api methods in the following section.


write( element_id:Number )
Builds the embed in an iframe, which is written inside specified target's innerHTML. We recommend using a DIV tag or other block-level element with this method.
seamless( element_id:Number )
An alternative to write that will render the document without an iframe, making it look like part of the page, rather than a separate embed. The document will fill its full height on the page, and can be navigated using the top level scrollbar. See the seamless embedding example application. Note: only compatible with the Scribd.Document.getDoc constructor.
addParam( key:Number, value:String )
Used to specify Scribd Reader attributes and behavior. Must be called before write(). See the parameter section below for supported parameters.
getFormat( ):String
Returns the format that is the document is loaded with, either 'html5' or 'flash'.
addEventListener( eventType:String, callback:Function )
Used to assign a listener to Scribd Reader events. See the events section for supported event types, and the examples section for relevant sample code.

HTML5 Reader Only

removeEventListener( eventType:String, callback:Function )
Used to remove a Scribd Reader event listener. See the events section for supported event types, and the examples section for relevant sample code.
api.getPageCount( ):Number
Returns the total number of pages in the document.
api.getPage( ):Number
Returns the current page as displayed in the toolbar.
api.setPage( pageNumber:Number )
Jumps to the specified page. Input is bound between 0 and the current page count.
api.getZoom( ):Number
Returns the current zoom factor, where a value of 1 is equal to a zoom factor of 100%.
api.setZoom( zoomFactor:Number )
Accepts a zoom factor, where a value of 1 is equal to a zoom factor of 100%.
api.getDocumentId( ):String
Returns the document ID of the most recently loaded document.
api.getViewMode( ):String
Returns the current view mode of Scribd Reader as one of the following strings: 'list', 'book', 'slideshow', 'tile'. (Only 'list' and 'slideshow' are supported by the HTML5 embed.)
api.loadDocument( document_id:String, access_key:String )
Loads a document using its document id and access key.

Flash Reader Only

api.getVerticalScroll( ):Number
Returns a position value, in the format required by api.setVerticalScroll().
api.setVerticalScroll( scrollPosition:Number )
Parameter should be in the format of page.fraction, where the integer represents which page to scroll to and the fraction represents how far down that page to scroll. For example, a value of 7.5 will scroll the viewport's upper edge to the second half of page seven.
api.getHorizontalScroll( ):Number
Returns a position value, in the format required by api.setHorizotalScroll().
api.setHorizontalScroll( scrollPosition:Number )
A number between 0 and 1 which specifies where to align the left edge of the viewport. For example, a value of .5 will scroll the viewport so the left edge is aligned with the center of the current page. Input is sensibly bound between 0 and 1.
api.getFullscreen( ):Boolean
Returns true if Scribd Reader is currently in fullscreen mode, false if not.
api.setFullscreen( fullscreen:Boolean )
If fullscreen is true, Scribd Reader is switched into the fullscreen state. If false, Scribd Reader will return to its normal state.


See addEventListener() or examples for more information.

Signals when it's safe to begin using the api object methods. Fired when the document has finished successfully loading the first page of the current document.
Fired whenever a user has moved to a new page. Use api.getPage() to get the new page.
Fired when Scribd Reader has changed view modes. Use api.getViewMode() to get the current view mode.
Fired when the zoom level has changed. Use api.getZoom() to get the current zoom level.
deprecated Use 'docReady' instead. Signals when it's safe to begin using the api object methods. Fired when iPaper has finished successfully loading the first page of the current document.

addParam() Parameters

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

'default_embed_format' => string
The default format of the Scribd Reader. Options are 'html5' and 'flash'. Defaults to 'html5'.
'height' => integer
The height of Scribd Reader, in pixels. If this is not specified, Scribd Reader will attempt to size itself correctly for the webpage it's embedded in.
'width' => integer
The width of Scribd Reader, in pixels. If this parameter is not sepecified, Scribd Reader 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 Scribd Readers created with the getDocFromUrl constructor. Scribd Readers created with the getDoc constructor will ignore this parameter.
'page' => integer
You can use this to scroll Scribd Reader to a default start page. Defaults to 1.
'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 Scribd Readers 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 Scribd Readers created from the getDocFromUrl constructor.

Sets the title of the new file uploaded.
'jsapi_version' => integer
Specify the interface version you're targeting. We require this parameter so we can add new API features without breaking existing installations. The most current supported interface is version 2.
'mode' => string
Sets the default view mode for the document, overriding the document's default. Parameter must be added before the document is written. Valid values are: 'list', 'book', 'slideshow', and 'tile'. Only 'list' and 'slideshow' are supported for the HMTL5 Reader.
'allow_share' => boolean
Defines whether the share button in the toolbar is shown, overriding the default (true unless the document is flagged as private). Parameter must be added before the document is written.

Flash Reader Only

'search_query' => string
A string of keywords to highlight in Scribd Reader. If the user is coming from a search engine, this parameter should contain the user's raw search query. The user's query will be stripped of stopwords and delimeted by spaces before highlighting.
'disable_related_docs' => boolean
Disables the related documents tab in List Mode.
'hide_disabled_buttons' => boolean
Hides all disabled buttons.
'hide_full_screen_button' => boolean
Hides the fullscreen button and disables switching to fullscreen mode, if set.
'full_screen_type' => string
Sets the type of the fullscreen mode Scribd Reader will switch to when fullscreen button is pressed. Valid values are: "js", "flash", "url":
flash: Display true fullscreen mode of Flash Player.
js: Maximize Scribd Reader within the browser window.
url: Go to fullscreen url of the document on scribd.com.
'disable_resume_reading' => boolean
If set, does not display the toolbar message 'Click here to continue reading on page X'.

Keyword Highlighting in Scribd Flash Reader

To help users arriving at Scribd from search engines, we've implemented the ability to highlight the search query wherever it appears in a document. If query keywords are provided before the document has loaded, Scribd Reader will scroll to the first occurrence of a query term. (This is accomplished by adding the search query and, optionally, keywords as Scribd Reader parameters). NOTE: This is currently only supported by the Flash Reader.


A Simple Customization

Here, we'll download a document from the web, designate it as a public document, set the reader size, and render it to the page.

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

<script type="text/javascript">
  var url = 'http://lib.store.yahoo.net/lib/paulgraham/onlisp.ps';
  var pub_id = 'YOUR-SCRIBD-PUBLISHER-ID';
  var scribd_doc = scribd.Document.getDocFromUrl(url, pub_id);

  var onDocReady = function(e){

  scribd_doc.addEventListener('docReady', onDocReady);
  scribd_doc.addParam('jsapi_version', 2);
  scribd_doc.addParam('height', 600);
  scribd_doc.addParam('width', 400);
  scribd_doc.addParam('public', true);


Adding Interaction to the Scribd Reader

This final example demonstrates the power of the Scribd's JavaScript API. In this small sample application, you can see how to integrate custom behavior into our document reader, attaching custom content to scribd pages, and deep linking into the Scribd document.


HTML5 vs. Flash

Please note that the Flash version of the reader is obsolete. We recommend to use the default HTML5 reader instead.

Examples and Tutorials

Sample JS Application
Sample with Seamless Embedding

Technical Support

Having issues? First, check if the FAQ already has your answer. If not, you can post your questions on the Scribd Platform Google Group. This is the best way to get a quick answer.

If you have a private question that can't be posted on the group, you can email us directly at