In This Topic
Tutorials / Other Technologies / PHP / Integrating DocuVieware in your PHP client application

Integrating DocuVieware in your PHP client application

In This Topic
The purpose of this tutorial is to highlight the integration of the DocuVieware control into a client application, so please first be sure to follow the Serving DocuVieware through a REST API tutorial.
The source code of both REST service implementation and integration are available in your [INSTALL FOLDER]\Samples\ASP.NET\DocuVieware\ folder.

DocuVieware™ only requires its own resources, one JavaScript file and one CSS file, both can be found in your [SDK INSTALL DIR]\Redist\DocuVieware (Resources)\ folder. In the following examples, it will be assumed that they are available locally.

Copy Code
<script src="docuvieware-min.js"></script>
<link rel="stylesheet" type="text/css" href="docuvieware-min.css">

The last thing required is the complete and accurate URL your REST service is reachable at.

For this tutorial it is assumed that the service is locally running on the machine using the port 62968. The complete URL to the method is http://localhost:62968/api/DocuViewareREST/GetDocuViewareControl.
Be careful: your own implementation will most probably differ, especially the port that is usually randomly selected upon project creation by Visual Studio so be sure to adapt the URL to your configuration.

 Integration using PHP

Here is how to access the REST service using the PHP cURL library:

Integration using PHP
Copy Code
 header('Content-Type: text/html; charset=utf-8');
$docuViewareConfig = array(
     'SessionId' => session_id(),
    'ControlId' => 'DocuVieware1',
     'AllowPrint' => true,
     'EnablePrintButton' => true,
     'AllowUpload' => true,
     'EnableFileUploadButton' => true,
     'CollapsedSnapIn' => true,
     'ShowAnnotationsSnapIn' => true,
     'EnableRotateButtons' => true,
     'EnableZoomButtons' => true,
     'EnablePageViewButtons' => true,
     'EnableMultipleThumbnailSelection' => true,
     'EnableMouseModeButtons' => true,
     'EnableFormFieldsEdition' => true,
     'EnableTwainAcquisitionButton' => true
 $data_string = json_encode($docuViewareConfig);
$ch = curl_init('http://localhost:62968/api/DocuViewareREST/GetDocuViewareControl');
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     'Content-Type: application/json',
     'Content-Length: ' . strlen($data_string))
 $result = curl_exec($ch);
 if ($result === false) {
     $info = curl_getinfo($ch);
     die('Error occured during curl exec.: ' . var_export($info));
 $docuViewareControlHtml = $result;

Then, to integrate the result HTML markup in your client page, you can do the following:

Integrating the result HTML markup.
Copy Code
$html = json_decode($docuViewareControlHtml);
print $html->{'HtmlContent'};
See Also