10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PDFlib servlets and Java application servers. PDFlib is perfectly suited for server-sideJava applications, especially servlets. The PDFlib distribution contains examples ofPDFlib Java servlets which demonstrate the basic use. When using PDFlib with a specificservlet engine the following configuration issues must be observed:> The directory where the servlet engine looks for native libraries varies among vendors.Common candidate locations are system directories, directories specific to theunderlying Java VM, and local directories of the servlet engine. Please check the documentationsupplied by the vendor of your servlet engine.> Servlets are often loaded by a special class loader which may be restricted, or use adedicated classpath. For some servlet engines it is required to define a special engineclasspath to make sure that the PDFlib package will be found.More detailed notes on using PDFlib with specific servlet engines and Java applicationservers can be found in additional documentation in the PDFlib distribution.Note Since the EJB (Enterprise Java Beans) specification disallows the use of native libraries, PDFlibcannot be used within EJBs.Error Handling in Java. The Java binding installs a special error handler which translatesPDFlib errors to native Java exceptions. In case of an exception PDFlib will throw anative Java exception of the following class:PDFlibExceptionThe Java exceptions can be dealt with by the usual try/catch technique:try {...some PDFlib instructions...} catch (PDFlibException e) {System.err.print("PDFlib exception occurred in hello sample:\n");System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() +": " + e.get_errmsg() + "\n");} catch (Exception e) {System.err.println(e.getMessage());} finally {if (p != null) {p.delete(); /* delete the PDFlib object */}}Since PDFlib declares appropriate throws clauses, client code must either catch all possiblePDFlib exceptions, or declare those itself.Unicode and legacy encoding conversion. For the convenience of PDFlib users we listsome useful string conversion methods here. Please refer to the Java documentation formore details. The following constructor creates a Unicode string from a byte array, usingthe platform’s default encoding:String(byte[] bytes)32 Chapter 2: PDFlib Language Bindings

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!