How to Use PDFNet with JRuby?

46 views
Skip to first unread message

Vincent Ycasas

unread,
Aug 28, 2013, 5:08:28 PM8/28/13
to pdfne...@googlegroups.com
Question:
How do I use PDFNet library with JRuby?

Vincent Ycasas

unread,
Aug 28, 2013, 5:08:43 PM8/28/13
to pdfne...@googlegroups.com
Answer:
In order for JRuby to find the native PDFNetC library (PDFNetC.dll, libPDFNetC.so, libPDFNetC.dylib), it must be placed at the correct locations:

Windows:
  • Any of the directories specified in PATH environment variable.
  • Inside %WINDIR%\System32
Linux:
  • In /usr/lib or its derivatives (i.e. /usr/local/lib)
  • Any of the directories specified in LD_LIBRARY_PATH environment variable.
Mac:
  • Copy libPDFNetC.dylib to /Library/Java/Extensions/libPDFNetC.jnilib.
In addition to any of the above, an alternative way of specifying where the native library resides is by adding -J-Djava.library.path option to jruby (of course, this will only work when running from command line interface).

The file PDFNet.jar must also be placed in the lib folder of JRuby.

Vincent Ycasas

unread,
Aug 29, 2013, 2:31:59 PM8/29/13
to pdfne...@googlegroups.com
Answer:
When using PDFNet with JRuby, it is also important to keep in mind that JRuby loads the Java API instead of the Ruby API. PDFNet's Ruby API is based on the C++ API and is using PascalCase for methods names, where as the Java API is using camelCase for method names.

PDFNet.Initialize("ABC") # PascalCase, works for Ruby but not for JRuby

PDFNet.initialize("ABC") # camelCase, works for JRuby but not for Ruby

Reply all
Reply to author
Forward
0 new messages