久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

利用Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向的實(shí)現(xiàn)方法

瀏覽:184日期:2022-05-20 14:08:15
Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向

本次程序測(cè)試環(huán)境如下:

Word測(cè)試文檔版本:.docx 2013

Word Jar包工具:free spire.doc.jar 3.9.0

代碼編譯工具:IDEA

Jdk版本:1.8.0

導(dǎo)入操作文檔所需的jar包工具,如圖結(jié)果:

利用Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向的實(shí)現(xiàn)方法

Java

import com.spire.doc.*;import com.spire.doc.documents.*;import com.spire.doc.fields.TextBox;import com.spire.doc.fields.TextRange;import java.awt.*;public class SetTextDirection { public static void main(String[] args) {//創(chuàng)建Word文檔Document doc = new Document();Section section = doc.addSection();//設(shè)置頁(yè)面邊距section.getPageSetup().getMargins().setLeft(90f);section.getPageSetup().getMargins().setRight(90f);Paragraph paragraph = section.addParagraph();//添加第一個(gè)文本框TextBox textBox1 = paragraph.appendTextBox(280, 250);//設(shè)置文本框?yàn)楣潭ǘㄎ籺extBox1.getFormat().setHorizontalOrigin(HorizontalOrigin.Page);textBox1.getFormat().setHorizontalPosition(150);textBox1.getFormat().setVerticalOrigin(VerticalOrigin.Page);textBox1.getFormat().setVerticalPosition(80);//設(shè)置文字旋轉(zhuǎn)方向textBox1.getFormat().setTextAnchor(ShapeVerticalAlignment.Center);textBox1.getFormat().setLayoutFlowAlt(TextDirection.Left_To_Right);//旋轉(zhuǎn)文字(逆時(shí)針)//textBox1.getFormat().setLayoutFlowAlt(TextDirection.Left_To_Right_Rotated);//文字豎排顯示//添加文字并設(shè)置字體Paragraph textboxPara1 = textBox1.getBody().addParagraph();TextRange txtrg = textboxPara1.appendText('姓名_______學(xué)號(hào)_________班級(jí)__________');txtrg.getCharacterFormat().setFontName('等線');txtrg.getCharacterFormat().setFontSize(10);txtrg.getCharacterFormat().setTextColor(Color.black);textboxPara1.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);//保存文檔doc.saveToFile('Result.docx');doc.dispose(); }}

執(zhí)行程序后,生成Word文檔,打開(kāi)該文檔后可查看文本框中的文字旋轉(zhuǎn)效果。通過(guò)設(shè)置不同旋轉(zhuǎn)效果,可查看文本框中的文字效果,如圖:

Left_To_Right旋轉(zhuǎn)效果:

利用Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向的實(shí)現(xiàn)方法

Left_To_Right_Rotated豎排顯示效果:

利用Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向的實(shí)現(xiàn)方法

延伸閱讀:

C# 設(shè)置Word文本框中的文字旋轉(zhuǎn)方向

到此這篇關(guān)于利用Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向的實(shí)現(xiàn)方法的文章就介紹到這了,更多相關(guān)Java設(shè)置Word文本框中的文字旋轉(zhuǎn)方向內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: word
相關(guān)文章:
主站蜘蛛池模板: 通渭县| 中西区| 策勒县| 甘谷县| 安达市| 顺义区| 华蓥市| 井研县| 绍兴县| 嘉祥县| 灵丘县| 陆川县| 汾阳市| 永平县| 甘南县| 嘉兴市| 个旧市| 磴口县| 竹溪县| 吴川市| 平安县| 灵武市| 北京市| 垣曲县| 宿迁市| 珲春市| 恩施市| 英山县| 枞阳县| 林甸县| 丰原市| 台南县| 新野县| 来安县| 子洲县| 安吉县| 纳雍县| 长治市| 光泽县| 清水县| 棋牌|