Created
August 19, 2011 04:55
-
-
Save rurounijones/1156073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-rw-r--r-- 1 jjones jjones 45812 2011-08-24 10:05 jmupdf.jar | |
-rw-r--r-- 1 jjones jjones 6912164 2011-08-24 10:05 libjmupdf32.so | |
-rw-r--r-- 1 jjones jjones 7150456 2011-08-24 10:16 libjmupdf64.so | |
-rw-r--r-- 1 jjones jjones 2006604 2011-08-18 13:55 test.pdf | |
-rw-r--r-- 1 jjones jjones 479 2011-10-31 15:38 test.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jruby -d -J-Djava.library.path=/home/jjones/Projects/jmupdftest/ test.rb | |
java.lang.ClassNotFoundException: com.jmupdf.PdfDocument | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) | |
at org.jruby.util.JRubyClassLoader.findClass(JRubyClassLoader.java:86) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) | |
at java.lang.Class.forName0(Native Method) | |
at java.lang.Class.forName(Class.java:247) | |
at org.jruby.javasupport.JavaSupport.loadJavaClass(JavaSupport.java:136) | |
at org.jruby.javasupport.JavaSupport.loadJavaClassVerbose(JavaSupport.java:145) | |
at org.jruby.javasupport.JavaClass.forNameVerbose(JavaClass.java:1183) | |
at org.jruby.javasupport.Java.getProxyOrPackageUnderPackage(Java.java:912) | |
at org.jruby.javasupport.Java.get_proxy_or_package_under_package(Java.java:945) | |
at org.jruby.javasupport.JavaUtilities.get_proxy_or_package_under_package(JavaUtilities.java:54) | |
at org.jruby.javasupport.JavaUtilities$s$2$0$get_proxy_or_package_under_package.call(JavaUtilities$s$2$0$get_proxy_or_package_under_package.gen:65535) | |
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:201) | |
at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59) | |
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104) | |
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) | |
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75) | |
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:120) | |
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:145) | |
at org.jruby.javasupport.util.RuntimeHelpers$MethodMissingMethod.call(RuntimeHelpers.java:497) | |
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:203) | |
at org.jruby.runtime.callsite.CachingCallSite.callMethodMissing(CachingCallSite.java:379) | |
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:289) | |
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:135) | |
at test.__file__(test.rb:4) | |
at test.load(test.rb) | |
at org.jruby.Ruby.runScript(Ruby.java:671) | |
at org.jruby.Ruby.runNormally(Ruby.java:575) | |
at org.jruby.Ruby.runFromMain(Ruby.java:424) | |
at org.jruby.Main.doRunFromMain(Main.java:278) | |
at org.jruby.Main.internalRun(Main.java:198) | |
at org.jruby.Main.run(Main.java:164) | |
at org.jruby.Main.run(Main.java:148) | |
at org.jruby.Main.main(Main.java:128) | |
NameError: cannot load Java class com.jmupdf.PdfDocument | |
get_proxy_or_package_under_package at org/jruby/javasupport/JavaUtilities.java:54 | |
method_missing at /home/jjones/.rvm/rubies/jruby-1.6.3/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb:51 | |
(root) at test.rb:4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The example file I am working from | |
package com.examples.convert; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
import com.jmupdf.PdfDocument; | |
import com.jmupdf.PdfPage; | |
import com.jmupdf.PdfRenderer; | |
import com.jmupdf.exceptions.PDFException; | |
import com.jmupdf.exceptions.PDFSecurityException; | |
/** | |
* Create a BufferedImage from a PdfPage object | |
* | |
*/ | |
public class Pdf_2_BufferedImage { | |
public static void main(String[] args) { | |
try { | |
/* | |
* Open document | |
*/ | |
PdfDocument pdfDoc = new PdfDocument("c:\\tmp\\test1.pdf"); | |
/* | |
* Get page object | |
*/ | |
PdfPage page = pdfDoc.getPage(1); | |
/* | |
* Get rendering object | |
*/ | |
PdfRenderer render = new PdfRenderer(page, 1f, PdfPage.PAGE_ROTATE_AUTO, PdfRenderer.IMAGE_TYPE_RGB); | |
render.render(true); | |
/* | |
* Save to disk for review | |
*/ | |
ImageIO.write(render.getImage(), "PNG", new File("c:\\tmp\\test1.png")); | |
/* | |
* Dispose | |
*/ | |
render.dispose(); | |
pdfDoc.dispose(); | |
} catch (PDFException e) { | |
e.printStackTrace(); | |
} catch (PDFSecurityException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The extremely simple jruby test | |
require 'java' | |
require 'jmupdf.jar' | |
pdf_file = com.jmupdf.PdfDocument.new(File.read('test.pdf').to_java_bytes) | |
# NameError: cannot load Java class com.jmupdf.PdfDocument | |
# get_proxy_or_package_under_package at org/jruby/javasupport/JavaUtilities.java:54 | |
# method_missing at /home/jjones/.rvm/rubies/jruby-1.6.3/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb:51 | |
# (root) at test.rb:4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment