Tambah teks utawa gambar watermark menyang PDF dokumen nggunakake Java. Muat PDF dokumen lan lebokake tandha banyu sing dibutuhake. Banjur simpen asil ing format sing trep kayata DOCX, PDF, MD, HTML, TXT, DOC, RTF, EPUB, XPS lan liya-liyane, lan nuduhake dokumen sing diwenehi tandha banyu karo wong liya. Uga mbusak tandha banyu saka PDF dokumen yen tandha banyu sadurunge ditambahake menyang dokumen, lan alasan kanggo nambah ora relevan maneh.
Kanthi API Java iki, pangembang bisa nambah tandha banyu menyang PDF online. Mung nggawe watermark nggunakake teks utawa gambar banjur lebokake watermark menyang PDF dokumen ing Java.
Cathetan: ora perlu nginstal aplikasi utawa perpustakaan pihak katelu. Mulane, solusi piranti lunak Java kita gampang banget digunakake.
SDK Java sing diwenehake uga mbiyantu mbusak tandha banyu saka PDF. Mbusak tandha banyu ing PDF tegese sampeyan bisa mbukak PDF dokumen sing dipengini kanthi prangko teks utawa gambar, mbusak tandha banyu iki saka PDF nggunakake Java, banjur simpen file output ing format sing trep - DOC, DOCX, PDF, JPEG, PNG, TIFF lan liya-liyane.
Kanggo ngevaluasi carane nambah utawa mbusak tandha banyu ing PDF nganggo API Java, muat PDF lan tandha banyu minangka gambar utawa teks. Banjur pilih format file ekspor sing trep - DOC, DOCX, PDF, HTML, RTF, XPS lan liya-liyane.
Gunakake conto ing ngisor iki kanggo ndeleng cara kerjane:
import com.aspose.words.cloud.*;
ApiClient apiClient = new ApiClient("####-####-####-####-####", "##################", null);
WordsApi wordsApi = new WordsApi(apiClient);
byte[] requestDocument = Files.readAllBytes(Paths.get("Input1.pdf").toAbsolutePath());
byte[] requestImageStream = Files.readAllBytes(Paths.get("Input2.jpg").toAbsolutePath());
WatermarkDataImage requestWatermarkData = new WatermarkDataImage();
requestWatermarkData.setImage(new FileReference(requestImageStream));
InsertWatermarkOnlineRequest insertWatermarkRequest =
new InsertWatermarkOnlineRequest(requestDocument, requestWatermarkData,
null, null, null, null, null, null, null, null);
InsertWatermarkOnlineResponse insertWatermarkResult =
wordsApi.InsertWatermarkOnline(insertWatermarkRequest);
ConvertDocumentRequest convertRequest = new ConvertDocumentRequest(
insertWatermarkResult.getDocument().iterator().next(), "pdf",
null, null, null, null, null, null, null);
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.pdf").toAbsolutePath());
WatermarkDataText requestWatermarkData = new WatermarkDataText();
requestWatermarkData.setText("This is the watermark text");
requestWatermarkData.setLayout(WatermarkDataText.LayoutEnum.DIAGONAL);
InsertWatermarkOnlineRequest insertWatermarkRequest =
new InsertWatermarkOnlineRequest(requestDocument, requestWatermarkData,
null, null, null, null, null, null);
InsertWatermarkOnlineResponse insertWatermarkResult =
wordsApi.InsertWatermarkOnline(insertWatermarkRequest);
ConvertDocumentRequest convertRequest = new ConvertDocumentRequest(
insertWatermarkResult.getDocument().iterator().next(), "pdf",
null, null, null, null, null, null, null);
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.pdf").toAbsolutePath());
DeleteWatermarkOnlineRequest deleteWatermarkOnline =
new DeleteWatermarkOnlineRequest(requestDocument, null, null, null, null, null, null);
DeleteWatermarkOnline deletedWatermark = wordsApi.deleteWatermarkOnline(deleteWatermarkOnline);
ConvertDocumentRequest convertDocument = new ConvertDocumentRequest(
deletedWatermark.getDocument().iterator().next(), "pdf",
null, null, null, null, null, null, null);
wordsApi.convertDocument(convertDocument);
Instal 'Aspose.Words Cloud SDK for Java' nggunakake alat otomatisasi mbangun Maven.
Tambah ketergantungan iki menyang POM proyek sampeyan:
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.
Deleng Repository Documentation kanggo ndeleng rincian.
Sampeyan bisa nambah watermark menyang dokumen ing format liyane: