Over a million developers have joined DZone.

Pulling a PDF Using Scribd API and PHP

DZone 's Guide to

Pulling a PDF Using Scribd API and PHP

· Web Dev Zone ·
Free Resource

I am creating a platform that provides print capabilities for the social reading and publishing platform, Scribd. This will allow any user to print a document on the cloud storage platform, and pass the ID to the Mimeo Connect Cloud Print Platform.

I want to share each step of the process so that others may take advantage of the code I’m writing.

My goal is to pull a specific file from the Scribd platform. I need a PDF, and Scribd provides this via the Scribd API.

I went to Scribd and logged into my account, clicked on Developers / API link on the bottom of their site and applied for an API key. Now I’m able to make calls against the API.

I went and found the document I wanted to pull, The Future of Reading and Publishing is Social, and grabbed the ID of the document. It is located in the URL right after the /doc/37360086/.

Then using the simplexml_load_file() PHP function I GET the file information using the Scribd API:

$Scribd_API_Key = "[api key]“;
$Scribd_Document_ID = “37360086″;
$Scribd_URL = “http://api.scribd.com/api?method=print.getPrintInfo&api_key=” . $Scribd_API_Key . “&doc_id=” . $Scribd_Document_ID;
$xml = simplexml_load_file($Scribd_URL);

$Title = $xml->title;
$Download_Link = $xml->download_link;
$Page_Count = $xml->page_count;
$Height = $xml->height;
$Width = $xml->width;
$DPI = $xml->dpi;
This call returns an XML response containing relevant file information:
<rsp stat=”ok”>
The Future of Reading and Publishing is Social

Now I can pull the PDF file and begin using for my cloud print ordering process. Next I will need to proof the document before I can display for the user.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}