PDF writer is not working

s shivratan gupta 3 years 7 months ago
17 2 0

Hi ,

i m using the pdf writer to generate the PDF file on Android platform,

but when i pass the the image path to pdf.add_image its giving me the error.

require 'pdf/writer.rb'

require 'pdf/open-uri'
require 'pdf/simpletable.rb'

   def make_pdf
        # prepare DPF file on local file system in User folder
        #
        # for generate PDF we use open source pure Ruby library PDF-Writer
        # Homepage::  http://rubyforge.org/projects/ruby-pdf/
        # Copyright:: 2003-2005, Austin Ziegler
        #
        # PDF-Writer also require few additional Ruby libs:
        #   color
        #   transaction-simple
        #   thread
        #
        # You can see their Ruby code in rodes platform extension folder:
        #  [Rhodes root]/lib/extensions
        #
        # for include that libs to your application you should add next extsnions to your application extension list in your application build.yml :
        # "pdf-writer", "thread"
        #

        pdf = PDF::Writer.new
        pdf.select_font("Helvetica")

      i have used all below method but isa giving same error and not allowing to add the image to pdf file
      1)pdf.add_image
      2)pdf.image
      3)pdf.add_image_from_file

      pdf.image "#{Rho::RhoApplication.get_base_app_path()}public/images/loading_1.JPEG", :resize => 0.75
    
      pdf.image Rho::RhoApplication.get_base_app_path() + "public/images/Jellyfish.jpeg", :resize => 0.75
      imgreturn = pdf.add_image_from_file(Rho::RhoApplication.get_base_app_path() + "public/images/Jellyfish.jpg", 0,0)
    
      file_location = File.join('/demo','demo.pdf')
    
      pdf.save_as(file_location)
      pdf = Prawn::Doccument.new
    
        redirect :action => :index
  end
 
is donot allow to add the image to pdf.

please anyone has idea then please help me...i m new to rhodes application development

thanks you soo much..

Please Register or Login to post a reply

2 Replies

J Jon Tara

See my response to your other post.

Rhodes does not support Ruby threads on Android.

Maybe parts of PDF-writer will work, if those parts don't need a Ruby thread.

It's always good to post specific error messages, not just "doesn't work", or "doesn't allow to add the images to PDF".

s shivratan gupta

Hi Jon,

Thanks for your reply

when i am using the

1)pdf.add_image method  in internally call the

info = PDF::Writer::Graphics::ImageInfo.new(image_data)

it not giving me the proper info...when i do the
info.format it giving me the "OTHER" but my image is .jpeg file
and also when i do the info.height or info.weight it giving me the nil value

and when if i hardcode the height and weight then its open the pdf file with blank pdf ..no image added on pdf.

CONTACT
Can’t find what you’re looking for?