Created
September 10, 2008 06:07
-
-
Save wycats/9832 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>My First Document</title> | |
<style type="text/css"> b { color: green; } </style> | |
</head> | |
<body> | |
<p> | |
<b>Greetings Earthlings!</b> | |
We've come for your Java. | |
</p> | |
</body> | |
</html> |
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
require "core-renderer" | |
require "minium" | |
require "itext-paulo-155" | |
require "java" | |
import org.jruby.util.IOOutputStream | |
import com.lowagie.text.DocumentException | |
import org.xhtmlrenderer.pdf.ITextRenderer | |
input_file = "#{File.expand_path(File.dirname(__FILE__))}/humor.html" | |
output_file = "firstdoc.pdf" | |
File.open(output_file, 'w') do |file| | |
renderer = ITextRenderer.new | |
renderer.document = "file:/#{input_file}" | |
renderer.layout | |
renderer.create_PDF(IOOutputStream.new(file)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment