Monthly Archives: February 2014

PDF SDK bindings for PHP, Python, and Ruby

PDFTron open sources PDFNet language bindings for PHP, Python, and Ruby.

We are happy to announce that the source code for the PHP, Python, and Ruby bindings for PDFNet are now open source.

This is in response to many PDFNet customers needing support for specific language versions. Previously, PDFTron’s pre-compiled bindings supported only specific versions of these languages (specifically PHP 5.3, Python 2.7/3.2, and Ruby 1.9). It was clear that PDFNet users required more flexibility to support different languages, versions, and system configurations.

By open sourcing PDFNet SWIG bindings, PDFTron clients are now in full control over programming languages, platforms, and environments used in their solutions.

Besides using PDFNet with PHP, Python, and Ruby, the provided interface files can be used as a template to interface PDFNet with other programming languages (such as Lua, Go, Mono, D, Perl, R, Ocaml, and other languages supported by SWIG).

To get started, please follow the instructions provided in the README.txt. We welcome community feedback, pull requests, and additional language extensions.

PDFNet SWIG Project on GitHub:

Mobile Cross-Platform PDF Viewers: Options for Android, iOS, Windows Store (UWP) Apps

The rise of mobile platforms, each with its own native programming language and API, has created new demand for cross-platform development tools and SDKs. To display a PDF, most cross-platform toolkits offer either a C++ interface (which do not provide a native UI component) or might be a simple PDF-to-image style solution. In this post, we will outline some better options for handling PDFs in a cross-platform manner on mobile devices.

Continue reading

Exception Handling in PDFNet for Windows Store apps

Starting with PDFNet SDK 6.2.0-BETA for Windows Store apps, it is now possible to get more useful error messages when PDFNet throws exceptions.

Due to limitations of the COM API boundary, only System.Exception could be passed from the PDFNet SDK to the consuming code. This limited the errors to those that were already defined and prevented custom information to be attached.

To overcome this, PDFNet SDK for Windows Store apps has a new class; pdfnet.Common.Exception that can be created with an HResult from a System.Exception and will be able to display the information relevant to the error that caused the Exception.

The following code snippet shows an example in how to use the new PDFNetException class:

string errText = "NONE";
	pdftron.PDF.PDFDoc doc = new pdftron.PDF.PDFDoc("not_valid");
catch (Exception ex)
	pdftron.Common.PDFNetException pdfNetEx = new pdftron.Common.PDFNetException(ex.HResult);
	errText = string.Format("Exeption at line {0} in file {1}", pdfNetEx.LineNumber, pdfNetEx.FileName);
	errText += Environment.NewLine;
	errText += string.Format("Message: {0}", pdfNetEx.Message);
MessageDialog errorDialog = new MessageDialog(errText);
await errorDialog.ShowAsync();

Will show the following error message:

This information will be very valuable to us if PDFNet throws an unexpected Exception. If you encounter an Exception while working with the PDFNet SDK for Windows Store apps, it is a good idea to include the full error from PDFNetException.ToSTring() with the description of the problem sent to our support team.