Class: Aspose::Cloud::Slides::Converter
- Inherits:
-
Object
- Object
- Aspose::Cloud::Slides::Converter
- Defined in:
- lib/Slides/converter.rb
Instance Method Summary collapse
-
#convert(slide_number, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
convert a document to SaveFormat.
-
#convert_local_file(input_file_path, output_filename, save_format) ⇒ Object
convert a document to other formats without using storage.
-
#convert_to_image(slide_number, image_format, width, height, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
Saves a particular slide into various formats with specified width and height.
-
#convert_with_additional_settings(save_format = 'pdf', text_compression = '', embed_full_fonts = '', compliance = '', jpeg_quality = '', save_metafiles_as_png = '', pdf_password = '', embed_true_type_fonts_for_ascii = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
Convert PowerPoint Documents to other File Formats with Additional Settings.
-
#initialize(filename) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(filename) ⇒ Converter
Returns a new instance of Converter.
5 6 7 8 9 |
# File 'lib/Slides/converter.rb', line 5 def initialize(filename) @filename = filename raise 'filename not specified.' if filename.empty? @base_uri = Aspose::Cloud::Common::Product.product_uri + '/slides/' + @filename end |
Instance Method Details
#convert(slide_number, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
convert a document to SaveFormat
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/Slides/converter.rb', line 42 def convert(, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'slide_number not specified.' if .nil? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/slides/#{}?format=#{save_format}" str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output.empty? output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |
#convert_local_file(input_file_path, output_filename, save_format) ⇒ Object
convert a document to other formats without using storage
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/Slides/converter.rb', line 63 def convert_local_file(input_file_path, output_filename, save_format) raise 'input_file_path not specified.' if input_file_path.empty? raise 'output_filename not specified.' if output_filename.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/slides/convert?format=#{save_format}" signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file_path, signed_str_uri) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output.empty? save_format = 'zip' if save_format.eql?('html') output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |
#convert_to_image(slide_number, image_format, width, height, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
Saves a particular slide into various formats with specified width and height
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/Slides/converter.rb', line 14 def convert_to_image(, image_format, width, height, folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'slide_number not specified.' if .nil? raise 'image_format not specified.' if image_format.empty? raise 'width not specified.' if width <= 0 raise 'height not specified.' if height <= 0 str_uri = "#{@base_uri}/slides/#{}" qry = Hash.new qry[:format] = image_format qry[:width] = width qry[:height] = height str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output.empty? output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{image_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |
#convert_with_additional_settings(save_format = 'pdf', text_compression = '', embed_full_fonts = '', compliance = '', jpeg_quality = '', save_metafiles_as_png = '', pdf_password = '', embed_true_type_fonts_for_ascii = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
Convert PowerPoint Documents to other File Formats with Additional Settings
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/Slides/converter.rb', line 85 def convert_with_additional_settings(save_format = 'pdf', text_compression = '', = '', compliance ='', jpeg_quality = '', = '', pdf_password = '', = '', folder_name = '', storage_type = 'Aspose', storage_name = '') str_uri = "#{@base_uri}?format=#{save_format}" str_uri += "&TextCompression=#{text_compression}" unless text_compression.empty? str_uri += "&EmbedFullFonts=#{}" unless str_uri += "&Compliance=#{compliance}" unless compliance.empty? str_uri += "&JpegQuality=#{jpeg_quality}" unless jpeg_quality.nil? str_uri += "&SaveMetafilesAsPng=#{}" unless str_uri += "&PdfPassword=#{pdf_password}" unless pdf_password.empty? str_uri += "&EmbedTrueTypeFontsForASCII=#{}" unless str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output.empty? output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |