原創(chuàng)|使用教程|編輯:張瑩心|2021-10-22 11:18:07.920|閱讀 525 次
概述:郵票可以保證文件的真實性和有效性,也可以使文件看起來更專業(yè)。由于 Microsoft Word 不提供內置圖章功能,您可以將圖像添加到 Word 文檔以模仿圖章效果。這在將文檔打印為紙張或 PDF 時很有用。在本文中,您將學習如何使用Spire.Doc for Java向 Word 文檔添加“圖章” 。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.Doc for Java 是一款專業(yè)的Java Word組件,開發(fā)人員使用它可以輕松地將Word文檔創(chuàng)建、讀取、編輯、轉換和打印等功能集成到自己的Java應用程序中。
郵票可以保證文件的真實性和有效性,也可以使文件看起來更專業(yè)。由于 Microsoft Word 不提供內置圖章功能,您可以將圖像添加到 Word 文檔以模仿圖章效果。這在將文檔打印為紙張或 PDF 時很有用。在本文中,您將學習如何使用Spire.Doc for Java向 Word 文檔添加“圖章” 。
>>可點擊此處下載最新版測試。
將圖像圖章添加到 Word 文檔
Spire.Doc for Java 允許開發(fā)人員使用下表中列出的核心類和方法來添加和格式化圖像,使其看起來像 Word 文檔中的圖章。
姓名 | 描述 |
DocPicture 類 | 表示 Word 文檔中的圖片。 |
Paragraph.appendPicture() 方法 | 將圖像附加到段落末尾。 |
DocPicture.setHorizontalPosition() 方法 | 設置圖片的絕對水平位置。 |
DocPicture.setVerticalPosition() 方法 | 設置圖片的絕對垂直位置。 |
DocPicture.setWidth() 方法 | 設置圖片寬度。 |
DocPicture.setHeight 方法 | 設置圖片高度。 |
DocPicture.setTextWrappingStyle() 方法 | 設置圖片的文字環(huán)繞類型。 |
詳細步驟如下:
import com.spire.doc.*; import com.spire.doc.documents.Paragraph; import com.spire.doc.documents.TextWrappingStyle; import com.spire.doc.fields.DocPicture; public class AddStamp { public static void main(String[] args) { //Create a Document instance Document doc = new Document(); //Load a Word document doc.loadFromFile("test.docx"); //Get the specific paragraph Section section = doc.getSections().get(0); Paragraph paragraph = section.getParagraphs().get(4); //Add an image DocPicture picture = paragraph.appendPicture("cert.png"); //Set the position of the image picture.setHorizontalPosition(240f); picture.setVerticalPosition(120f); //Set width and height of the image picture.setWidth(150); picture.setHeight(150); //Set wrapping style of the image to In_Front_Of_Text, so that it looks like a stamp picture.setTextWrappingStyle(TextWrappingStyle.In_Front_Of_Text); //Save the document to file doc.saveToFile("AddStamp.docx", FileFormat.Docx); doc.dispose(); } }
整合所有格式API處理套包Spire.office for Java正在慧都網(wǎng)火熱銷售中!立馬1分鐘了解全部咨詢!
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn