Tips & Tricks

Using the ADBC JavaScript Object

September 05, 2003

Advertisement
Advertisement
 

ADBC or Acrobat Database Connectivity is a javascript object (derived from the Plugin) that allows you to connect to almost any type of database and display data directly in your PDF documents.

To demonstrate a quick example you'll need to download the example files acrotips.mdb, acrotips6006.pdf and AcroTips6006JS.txt. The example PDF has three buttons, one button connects to the database, and two other buttons to navigate the records in the sample database.

In the example database there is only one table 'Customers', there are five columns 'CustomerID', 'FirstName', 'LastName', 'SSN', 'Comments' and 'Address'. These match the form fields with the same names.

I have also created three form buttons 'Connect', 'First Record' and 'Next Record'.

To make life a little simpler the code required to make this example work is contained within one Document Level Javascript - 'AcroTips6006'. Inside the javascript are several 'functions' or blocks of processing code.

For example there is a function to connect to the database called 'Connect' activated by the Connect button, there is also one for the First Record button called 'firstRecord' and also one for the Next Record button 'nextRecord'.

Making a connection to a database is easy, you firstly need to create a Data Source Name [DSN] (Control Panel>ODBC/DataSources) - create a new DSN based on the Microsoft Access Database Driver, and select the 'acrotips.mdb' database.

The name you assign to the DSN is the name you use to connect to the database inside Javascript/Acrobat. It's that easy!

For example in the Connect function you will see a line of code as follows:

dbConn = ADBC.newConnection("AcroTips"); 

"AcroTips" was the name of the DSN I created (note the case). Once we have the 'connection' to the database we can execute Structure Query Language (SQL) statements against it.

If you now click the 'Connect' button the PDF will have a connection to the sample database and will let you look through the records in the database by using the other two form buttons.

To summarise this tip, the basic steps required are:

  • Create form fields to match those in your database.
  • Make a Data Source Name (DNS) using control panel and select your database.
  • Create a javascript function to connect to the database using the DSN assigned name as the connection name.
  • Create an execute an SQL Statement
  • Cycle over the query results by using buttons to activate other javascript functions. (ie, First Record and Next Record).

Copyright Dave Wraight & Planet PDF. No unauthorised reproduction, distribution or publication permitted.

Related Products at PDF Store

PitStop Professional

The industry standard that combines preflight, interactive editing and automated correction capabili... View full product details
Download free demo

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

PDFlib TET

Reliably extract text from any PDF file with this library/component. TET makes available the text co... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Download PDF Creator

Download The Best of Planet PDF volume 2
Planet PDF Newsletter
Most Popluar Articles
Features

Collating PDFs using JavaScript

Despite the numerous benefits, there can be potential issues with the conversion of paper documents into electronic archives. When scanning paper pages into PDF, it's possible to end up with the odd- and even-numbered pages in separate PDF files. It can be very time-consuming to collate them manually, but there is an easier way. Sean Stewart explains.

Featured Product

BCL easyPDF SDK

BCL easyPDF SDK is a set of PDF Programming Libraries designed specifically to help Software Developers / Programmers build and deploy enterprise class PDF applications for corporate wide PDF...

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit