Owahi Word file utawa PDF ing Java SDK

Gunakake REST API kanggo ngowahi file ing Java kanthi program

Nalika pangembang ngowahi dokumen nganggo solusi Java sing diwenehake, sing bener-bener diowahi yaiku Model Obyek Dokumen (DOM). Mangkono, meh kabeh owah-owahan bisa digawe kanggo document dituduhake minangka DOM. Kanthi Java SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup muat Word, PDF utawa file ing format muat sing didhukung, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing didhukung.

Ndeleng potongan kode

Sunting dokumen ing Java nggunakake REST API

Pustaka Java kita menehi pangembang kemampuan kanggo ngowahi dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.

Penting kanggo ngerti yen nggunakake solusi Java iki, sampeyan bisa ngowahi dokumen ing format apa wae sing didhukung. Contone, sampeyan bisa mbukak file ing PDF, DOCX, DOC, RTF, ODT, EPUB, HTML lan format liyane, banjur ngowahi file iki lan disimpen ing format sing padha utawa ing format sing didhukung liyane.

Sunting teks ing Java

Kasus sing paling populer kanggo nyunting Word, PDF utawa dokumen liyane yaiku nyunting teks. Kanthi solusi piranti lunak sing diwenehake, sampeyan bisa nambah, ngowahi utawa mbusak teks nggunakake Java ing dokumen kasebut.

Sunting tabel ing Java

Pilihan panyuntingan dokumen populer liyane yaiku nyunting tabel. Java SDK kita ngidini sampeyan nggarap tabel lan teks ing sel tabel.

Pangembang Java bisa nambah utawa mbusak sel tabel lan tabel, uga nambah, ngowahi lan mbusak teks ing njero.

Tambah gambar menyang dokumen nggunakake Java

Saliyane nyunting teks lan tabel, ana pilihan umum liyane: nambahake gambar menyang dokumen ing Java. Pangembang Java uga bisa nambah gambar menyang file nggunakake DOM.

Ngedit dokumen online

Coba Java SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan dokumen. Nggunakake conto ing ngisor iki, muat dokumen sampeyan lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang dokumen:

Unggah dokumen sing pengin diowahi
Kode roto
Unggah gambar sing pengin dilebokake
Pilih format target saka dhaptar
import com.aspose.words.cloud.*;

ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);

byte[] requestDocument = Files.readAllBytes(Paths.get(
   "Input.docx").toAbsolutePath());
ParagraphInsert requestParagraph = new ParagraphInsert();
requestParagraph.setText("Morbi enim nunc faucibus a.");

InsertParagraphOnlineRequest insertParagraphRequest = new InsertParagraphOnlineRequest(
   requestDocument, requestParagraph, null, null, null, null, null, null, null, null);
InsertParagraphOnline insertParagraph = wordsApi.insertParagraphOnline(insertParagraphRequest);

ConvertDocumentRequest convertRequest = new ConvertDocumentRequest(
   insertParagraph.getDocument().iterator().next(), "docx", null, null, null, null);
ConvertDocument convert = wordsApi.convertDocument(convertRequest);
import com.aspose.words.cloud.*;

ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);

byte[] requestDocument = Files.readAllBytes(Paths.get(
   "Input.docx").toAbsolutePath());
TableInsert requestTable = new TableInsert();
requestTable.setColumnsCount(1);
requestTable.setRowsCount(2);

InsertTableOnlineRequest insertTableRequest = new InsertTableOnlineRequest(requestDocument, 
   requestTable, "", null, null, null, null, null, null);
InsertTableOnline insertTable = wordsApi.insertTableOnline(insertTableRequest);

ConvertDocumentRequest convertRequest = new ConvertDocumentRequest(
   insertTable.getDocument().iterator().next(), "docx", null, null, null, null);
ConvertDocument convert = wordsApi.convertDocument(convertRequest);
import com.aspose.words.cloud.*;

ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);

byte[] requestDocument = Files.readAllBytes(Paths.get(
   "Input1.docx").toAbsolutePath());
DrawingObjectInsert requestDrawingObject = new DrawingObjectInsert();
requestDrawingObject.setHeight((double)0);
requestDrawingObject.setLeft((double)0);
requestDrawingObject.setTop((double)0);
requestDrawingObject.setWidth((double)0);
requestDrawingObject.setRelativeHorizontalPosition(
   DrawingObjectInsert.RelativeHorizontalPositionEnum.MARGIN);
requestDrawingObject.setRelativeVerticalPosition(
   DrawingObjectInsert.RelativeVerticalPositionEnum.MARGIN);
requestDrawingObject.setWrapType(DrawingObjectInsert.WrapTypeEnum.INLINE);

byte[] requestImageFile = Files.readAllBytes(Paths.get(
   "Input2.docx").toAbsolutePath());
InsertDrawingObjectOnlineRequest insertDrawingObjectRequest = 
   new InsertDrawingObjectOnlineRequest(requestDocument, requestDrawingObject, 
      requestImageFile, "sections/0", null, null, null, null, null, null);
InsertDrawingObjectOnline insertDrawingObject = 
   wordsApi.insertDrawingObjectOnline(insertDrawingObjectRequest);

ConvertDocumentRequest convertRequest = new ConvertDocumentRequest(
   insertDrawingObject.getDocument().iterator().next(), "docx", null, null, null, null);
ConvertDocument convert = wordsApi.convertDocument(convertRequest);
Kode roto
  
Nyalin kode Java menyang clipboard

Carane ngowahi file ing Java

  1. Pasang 'Aspose.Words Cloud kanggo Java'
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Java sampeyan
  3. Muat dokumen sing arep diowahi ing Java
  4. Lebokake isi ing wiwitan dokumen
  5. Download dokumen asil saka panyimpenan maya

Java perpustakaan kanggo nggunakake panyuntingan dokumen

Instal 'Aspose.Words Cloud SDK for Java' nggunakake alat otomatisasi mbangun Maven.

Tambah ketergantungan iki menyang POM proyek sampeyan: aspose-cloud artifact.aspose-cloud-releases http://artifact.aspose.cloud/repo com.aspose aspose-words-cloud 22.4.0

Minangka alternatif, sampeyan bisa clone Aspose.Words Cloud SDK for Java saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.