Class: Aspose::Cloud::Words::MailMerge
- Inherits:
-
Object
- Object
- Aspose::Cloud::Words::MailMerge
- Defined in:
- lib/Words/mail_merge.rb
Instance Method Summary collapse
-
#execute_mail_merge(str_xml) ⇒ Object
Executes mail merge without regions.
-
#execute_mail_merge_with_regions(str_xml) ⇒ Object
Executes mail merge with regions.
-
#execute_template(str_xml) ⇒ Object
Executes mail merge with regions.
-
#initialize(filename) ⇒ MailMerge
constructor
A new instance of MailMerge.
Constructor Details
#initialize(filename) ⇒ MailMerge
Returns a new instance of MailMerge.
8 9 10 |
# File 'lib/Words/mail_merge.rb', line 8 def initialize filename @filename = filename end |
Instance Method Details
#execute_mail_merge(str_xml) ⇒ Object
Executes mail merge without regions.
@param string filename
@param string str_xml
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/Words/mail_merge.rb', line 18 def execute_mail_merge str_xml begin if @filename == '' raise 'Base file not specified.' end if str_xml == '' raise 'XML not specified.' end str_uri = $product_uri + '/words/' + @filename + '/executeMailMerge' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post(signed_str_uri,str_xml,{:accept=>'application/xml'}) stream_hash = JSON.parse(response_stream) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(stream_hash['Document']['FileName']) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#execute_mail_merge_with_regions(str_xml) ⇒ Object
Executes mail merge with regions.
@param string filename
@param string str_xml
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/Words/mail_merge.rb', line 63 def execute_mail_merge_with_regions str_xml begin if @filename == '' raise 'Base file not specified.' end if str_xml == '' raise 'XML not specified.' end str_uri = $product_uri + '/words/' + @filename + '/executeMailMerge?withRegions=true' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post(signed_str_uri,str_xml,{:accept=>'application/xml'}) stream_hash = JSON.parse(response_stream) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(stream_hash['Document']['FileName']) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#execute_template(str_xml) ⇒ Object
Executes mail merge with regions.
@param string filename
@param string str_xml
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 135 136 137 |
# File 'lib/Words/mail_merge.rb', line 105 def execute_template str_xml begin if @filename == '' raise 'Base file not specified.' end if str_xml == '' raise 'XML not specified.' end str_uri = $product_uri + '/words/' + @filename + '/executeTemplate' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post(signed_str_uri,str_xml,{:accept=>'application/xml'}) stream_hash = JSON.parse(response_stream) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(stream_hash['Document']['FileName']) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |