Nalika pangembang ngowahi Word dokumen nganggo perpustakaan Ruby iki, sing lagi diowahi yaiku Model Obyek Dokumen (DOM). Dadi, meh kabeh owah-owahan bisa ditindakake kanggo Word dokumen sing diwakili minangka DOM. Kanthi Ruby SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup mbukak Word, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing padha utawa sing didhukung.
Pustaka Ruby kita menehi pangembang kemampuan kanggo ngowahi Word dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.
Kasus sing paling populer kanggo nyunting Word file yaiku nyunting teks. Kanthi solusi piranti lunak sing diwenehake, sampeyan bisa nambah, ngowahi utawa mbusak teks nggunakake Ruby ing dokumen kasebut.
Pilihan editing Word liyane sing populer yaiku nyunting tabel. Ruby SDK kita ngidini sampeyan nggarap tabel lan teks ing sel tabel.
Pangembang Ruby bisa nambah utawa mbusak sel tabel lan tabel, uga nambah, ngowahi lan mbusak teks ing njero.
Saliyane nyunting teks lan tabel ing Word, ana pilihan umum liyane: nambahake gambar menyang dokumen ing Ruby. Pangembang Ruby uga bisa nambah gambar menyang Word file nggunakake DOM.
Coba Ruby SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan Word dokumen. Nggunakake conto ing ngisor iki, muat Word dokumen lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang Word dokumen:
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Input.docx')
request_paragraph = ParagraphInsert.new({:Text => 'Morbi enim nunc faucibus a.'})
insert_paragraph_request = InsertParagraphOnlineRequest.new(document: request_document,
paragraph: request_paragraph)
insert_paragraph = @words_api.insert_paragraph_online(insert_paragraph_request)
convert_request = ConvertDocumentRequest.new(
document: insert_paragraph.document.values[0], format: 'docx')
convert = @words_api.convert_document(convert_request)
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Input.docx')
request_table = TableInsert.new({:ColumnsCount => 1, :RowsCount => 2})
insert_table_request = InsertTableOnlineRequest.new(document: request_document,
table: request_table, node_path: '')
insert_table = @words_api.insert_table_online(insert_table_request)
convert_request = ConvertDocumentRequest.new(
document: insert_table.document.values[0], format: 'docx')
convert = @words_api.convert_document(convert_request)
require 'aspose_words_cloud'
AsposeWordsCloud.configure do |config|
config.client_data['ClientId'] = '####-####-####-####-####'
config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new
request_document = File.open('Input1.docx')
request_drawing_object = DrawingObjectInsert.new({:Height => 0, :Left => 0, :Top => 0,
:Width => 0, :RelativeHorizontalPosition => 'Margin',
:RelativeVerticalPosition => 'Margin', :WrapType => 'Inline'})
request_image_file = File.open('Input2.docx')
insert_drawing_object_request = InsertDrawingObjectOnlineRequest.new(
document: request_document, drawing_object: request_drawing_object,
image_file: request_image_file, node_path: 'sections/0')
insert_drawing_object = @words_api.insert_drawing_object_online(insert_drawing_object_request)
convert_request = ConvertDocumentRequest.new(
document: insert_drawing_object.document.values[0], format: 'docx')
convert = @words_api.convert_document(convert_request)
Instal Aspose.Words Cloud SDK for Ruby nggunakake layanan hosting RubyGems. gem install aspose_words_cloud kanggo nginstal paket kasebut. Minangka alternatif, sampeyan bisa kanthi manual kloning Aspose.Words Cloud SDK for Ruby saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.
Ruby 2.6 utawa luwih anyar
Deleng Repository Documentation kanggo ndeleng rincian.
Sampeyan bisa nindakake operasi suntingan kanggo format file liyane: