Class: Aspose::Cloud::Pdf::Extractor
- Inherits:
-
Object
- Object
- Aspose::Cloud::Pdf::Extractor
- Defined in:
- lib/Pdf/extractor.rb
Instance Method Summary collapse
-
#get_image_count(page_number) ⇒ Object
Gets number of images in a specified page @param number page_number.
-
#get_image_custom_size(page_number, image_index, image_format, width = 0, height = 0) ⇒ Object
Get the particular image from the specified page with the default image size @param int page_number @param int image_index @param string image_format @param int width @param int height.
-
#get_image_default_size(page_number, image_index, image_format) ⇒ Object
Get the particular image from the specified page with the default image size @param number page_number @param number image_index @param string image_format.
-
#initialize(filename) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(filename) ⇒ Extractor
Returns a new instance of Extractor.
8 9 10 |
# File 'lib/Pdf/extractor.rb', line 8 def initialize filename @filename = filename end |
Instance Method Details
#get_image_count(page_number) ⇒ Object
Gets number of images in a specified page
@param number page_number
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/Pdf/extractor.rb', line 16 def get_image_count page_number begin if page_number == '' raise 'page number not sepcified' end if @filename == '' raise 'filename not sepcified' end str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images' str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) return stream_hash['Images']['List'].length rescue Exception=>e print e end end |
#get_image_custom_size(page_number, image_index, image_format, width = 0, height = 0) ⇒ Object
Get the particular image from the specified page with the default image size @param int page_number @param int image_index @param string image_format @param int width @param int height
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/Pdf/extractor.rb', line 95 def get_image_custom_size page_number, image_index, image_format, width=0, height=0 begin if page_number == '' raise 'page number not sepcified' end if image_index == '' raise 'image index not sepcified' end if image_format == '' raise 'image format not sepcified' end if @filename == '' raise 'filename not sepcified' end str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images/' + image_index.to_s + '?format=' + image_format + '&width=' + width.to_s + '&height=' + height.to_s str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + image_index.to_s + '.' + image_format Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#get_image_default_size(page_number, image_index, image_format) ⇒ Object
Get the particular image from the specified page with the default image size @param number page_number @param number image_index @param string image_format
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/Pdf/extractor.rb', line 46 def get_image_default_size page_number, image_index, image_format begin if page_number == '' raise 'page number not sepcified' end if image_index == '' raise 'image index not sepcified' end if image_format == '' raise 'image format not sepcified' end if @filename == '' raise 'filename not sepcified' end str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images/' + image_index.to_s + '?format=' + image_format str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + image_index.to_s + '.' + image_format Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |