[rjb-users] RJB, iText generates blank pdf
Wes Hays
weshays at gmail.com
Thu Dec 13 01:37:21 EST 2007
Is anyone else using RJB and iText to fill PDFs successfully? I have a pdf that I created in Adobe Acrobat Professional with 3 text fields (Name, Age and Dog) with some additional text on the page. When I run the following code it generates a pdf with the fields filled in but the other text that I placed on the form is gone.
----------------------------------------
require 'rjb' # Version 1.0.11
Rjb::load(RAILS_ROOT + '/java/lib/iText-2.0.7.jar')
@byteArrayOutputStream = Rjb::import('java.io.ByteArrayOutputStream')
@acroFields = Rjb::import('com.lowagie.text.pdf.AcroFields')
@pdfReader = Rjb::import('com.lowagie.text.pdf.PdfReader')
@pdfStamper = Rjb::import('com.lowagie.text.pdf.PdfStamper')
@pdfFormField = Rjb::import('com.lowagie.text.pdf.PdfFormField')
@baos = @byteArrayOutputStream.new
@reader = @pdfReader.new_with_sig('Ljava.lang.String;', RAILS_ROOT + '/java/data/regform2.pdf')
@stamper = @pdfStamper.new_with_sig("Lcom.lowagie.text.pdf.PdfReader;Ljava.io.OutputStream;", @reader, @baos)
@form = @stamper.getAcroFields()
@stamper.close
f = File.new(RAILS_ROOT + '/java/data/regform_ruby2.pdf', "w")
f.syswrite @baos.toString
f.close
----------------------------------------
More information about the rjb-users
mailing list