PDF Display and Protection
Previous Top Next

How to display and protect PDF files using Thinstall

clip0496


Description
Download Link

Runnable Demo - See it in action!

Runnable Demo (EXE file) (1.5MB)


Data Files, DLL Files, Thinstall Project - everything you need to build it yourself.



Project files (ZIP file) (1.2MB)
This demo requires Thinstall Version 2.519 or higher to build & run.


Sample License Key: weupzdjgry6vjmue9s2v4abn (this license key is not computer-locked)


This sample demonstrates the following concepts:

ยท Packaging a PDF Viewer and PDF file into a single file with protection applied
1. Display PDF files on computers with or without Acrobat installed
2. Your PDF file always remain protected, it is never placed on the hard drive
4. User can only access PDF file after entering a license key
5. License keys can be locked to specific computers


A high level of how it works
Thinstall allows content developers to package virtually any application with a set of data files and provide DRM (digital rights management) capabilities so the data can only be viewed and access with permission.

DRM restrictions can be placed on the resulting package so that it can only be viewed for specific amounts of time, dates, or limited number of times. Because the data files are never extracted to the hard drive, the user cannot access the files without first going through the license system.

The basic process is combine:

1. A data viewer (in this case a PDF viewer application)
2. Any runtime & configuration files required by the viewer (typical DLL files and registry keys that are installed by the viewer)
3. The data files you want to protect. In this case it would be a PDF file.
4. A Thinstall security script which defines the user's ability to use things like SaveAs, Printing, and Cut & Paste.

For this example, we chose to use PDFReader - a free PDF Viewer provided by Foxit Software. This viewer can be redistributed without any copyright restrictions. PDFReader.exe comes with preview3.dll and also requires the system file urlmon.dll in order to run on versions of Windows that do not already have this DLL installed. We are also going to be using Thinstall's scripting system to allow us to disable PDFReader ability to use SaveAs and Printing.

Thinstall's scripting system requires vbscript.dll to be registered on the end user's computer before it can be used. Most versions of Windows have this DLL already installed, however we included it in our package so our application works on Windows 95 and above. To eliminate the need to register vbscript.dll (which modifies the user's registry and requires Admin permission), we use Thinstall's virtual registry system to make it appear vbscript.dll has already been registered.

Getting Started

A list of files we have included in our Thinstall project includes:

PDFReader.exe - The input EXE which will be run by Thinstall

Preview3.dll - A DLL required by PDFReader
Rd_eula.txt - License for PDFReader requires this must be distributed with PDFReader
Sample.pdf - The PDF file we are trying to protect
Vbscript.dll - Visual Basic Scripting Runtime, required for Thinstall's scripting
Vbsctipt.dll.threg - A Virtual registry file for vbscript.dll so no registry changes required
Urlmon.dll - A DLL required by our project not present on some versions of Windows
Urlmon.dll.threg - virtual registry information
Disable_saveas.vbs - A Thinstall script file that disables printing and saveas capability.
gdiplus.dll - This DLL is required by preview3.dll.


After adding all of these files to our project, we should see something like this:
clip0486

If we built this project right now and launched the resulting EXE PDFReader would run but it would not show the file we want the user to see. To have PDFReader automatically use the file in question, we need to tell Thinstall to supply a command-line argument to PDFReader.

clip0487

clip0488

By checking "Always use default command line arguments", Thinstall will force the command-line arguments you supplied to be passed to PDFReader. In this case we have supplied the virtual file c:\test\sample.pdf.

This is where Thinstall's virtual filesystem comes into play. We are going to modify sample.pdf's virtual path to make it always appear to exist at the path c:\test\sample.pdf (even if the user does not have this directory).

Double click on the sample.pdf file in your project to edit its virtual path properties.


clip0489


Now when we build the EXE, and run it - it should launch PDFReader.exe with sample.pdf as a command-line argument.

Adding Licensing and Copy Protection

Following the steps above, we have created a PDF file that can be viewed only in EXE format. The PDF contents are not accessible by the user, and the user is not able to Save or Print.

The next step in copy-protecting our PDF file is to restrict access to the file so it can only be viewed on authorized machines. To do this, we enable Thinstall's licensing system:

clip0490

To enable the License System, simply enter a password on this dialog:

clip0491
Now:
1. Close this dialog and click the Build! Button
2. Run the new EXE

You should see something like this:
clip0492

If the user clicks on Enter License Key, it will bring us to this screen:
clip0493

The user must then enter a license key provided by you. Above the text box where the user enters their license key, the user's machine ID is also displayed. The machine ID for each user will be different. You can request the user supply their machine ID to you before you generate a license key. This stops the user from using the same license on a different computer.

If you plan to issue machine-locked license keys, you must enter the user's license key on here:
(Found under Menu -> Link -> License System 2, Tab "Generate Key)
clip0494
After entering the user's license key, click on "Generate Key". This will create a license key which you can pass back to the user.