问题描述
我想从一个特定的段落内容在.DOCX复制到另一个空的.docx。问题我已经是该样式,子弹从source.docx编号等不保留在目标.DOCX 。这里是我的code
谁能告诉我什么将被添加到上述code中的变化?
在此先感谢!
公共类WordFinal { 公共静态无效的主要(字串[] args)抛出IOException异常,XmlException { XWPFDocument DOC =新XWPFDocument(新的FileInputStream(source.docx)); XWPFDocument destDoc =新XWPFDocument(); 出的OutputStream =新的FileOutputStream(Destination.docx); XWPFParagraph PR = doc.getParagraphs()[1]; 字符串复制= pr.getText(); XWPFParagraph paragraphOne = destDoc.createParagraph(); XWPFRun paragraphOneRunOne = paragraphOne.createRun(); paragraphOneRunOne.setText(复印件); destDoc.write(出); }
}
我使用POI彬3.10.1-20140818从库中的
您可以复制所有段落中的.docx文件循环 doc.getParagraphs()
但表并不是款,所以表是不可复制的。
要复制表,你必须得到的 IBodyElement 并循环 doc.getBodyElements()
进口java.io.FileInputStream中;
进口java.io.FileOutputStream中;
进口java.io.IOException异常;
进口java.io.OutputStream中;进口org.apache.poi.xwpf.usermodel.XWPFDocument;
进口org.apache.poi.xwpf.usermodel.XWPFParagraph;
进口org.apache.xmlbeans.XmlException;公共类WordFinal { 公共静态无效的主要(字串[] args)抛出IOException异常,XmlException { XWPFDocument DOC =新XWPFDocument(新的FileInputStream(source.docx)); XWPFDocument destDoc =新XWPFDocument(); 出的OutputStream =新的FileOutputStream(Destination.docx); // **此code将复制只是一个段落。 ** 。XWPFParagraph PR = doc.getParagraphs()得到(0); destDoc.createParagraph(); 。INT POS = destDoc.getParagraphs()尺寸() - 1; destDoc.setParagraph(PR,POS) destDoc.write(出); }
}
所以,code复制了所有段落和表像的下面。
进口java.io.FileInputStream中;
进口java.io.FileOutputStream中;
进口java.io.IOException异常;
进口java.io.OutputStream中;进口org.apache.poi.xwpf.usermodel.BodyElementType;
进口org.apache.poi.xwpf.usermodel.IBodyElement;
进口org.apache.poi.xwpf.usermodel.XWPFDocument;
进口org.apache.poi.xwpf.usermodel.XWPFParagraph;
进口org.apache.poi.xwpf.usermodel.XWPFTable;
进口org.apache.xmlbeans.XmlException;公共类WordFinal { 公共静态无效的主要(字串[] args)抛出IOException异常,XmlException { XWPFDocument DOC =新XWPFDocument(新的FileInputStream(source.docx)); XWPFDocument destDoc =新XWPFDocument(); 出的OutputStream =新的FileOutputStream(Destination.docx); 为(IBodyElement bodyElement:doc.getBodyElements()){ BodyElementType的ElementType = bodyElement.getElementType(); 如果(elementType.name()。等于(段落)){ XWPFParagraph PR =(XWPFParagraph)bodyElement; destDoc.createParagraph(); 。INT POS = destDoc.getParagraphs()尺寸() - 1; destDoc.setParagraph(PR,POS) }否则如果(elementType.name()。等于(TABLE)){ XWPFTable表=(XWPFTable)bodyElement; destDoc.createTable(); 。INT POS = destDoc.getTables()尺寸() - 1; destDoc.setTable(POS,表);
}
} destDoc.write(出);
}
}
但是,即使通过这样的方式,你不能复制的形象和风格。
所以复制文档看起来与原件不同。
似乎org.apache.poi.xwpf.usermodel.XWPFRun.addPicture()方法有错误。
包括XWPFRun.addPicture(添加图片)DOCX文档不是由Microsoft Word中打开。
[参考]
下面code为包括下一个功能。
1)复制段和表的内容和样式
2)副本页面布局
3)从复制源文件DOCX图像
包com.overflow.heeseok;进口java.io. *;
进口java.math.BigInteger的;
进口的java.util.List;进口org.apache.poi.openxml4j.exceptions.InvalidFormatException;
导入org.apache.poi.xwpf.usermodel *。
进口org.apache.xmlbeans.XmlException;
导入org.openxmlformats.schemas.wordprocessingml.x2006.main *。
进口org.openxmlformats.schemas.wordprocessingml.x2006.main.STPageOrientation.Enum;公共类WordFinal { 公共静态无效的主要(字串[] args)抛出IOException异常,XmlException
{
XWPFDocument srcDoc =新XWPFDocument(新的FileInputStream(Source.docx)); CustomXWPFDocument destDoc =新CustomXWPFDocument(); //复制文件中的布局。
copyLayout(srcDoc,destDoc); 出的OutputStream =新的FileOutputStream(Destination.docx); 为(IBodyElement bodyElement:srcDoc.getBodyElements()){ BodyElementType的ElementType = bodyElement.getElementType(); 如果(元素类型== BodyElementType.PARAGRAPH){ XWPFParagraph srcPr =(XWPFParagraph)bodyElement; copyStyle(srcDoc,destDoc,srcDoc.getStyles()的getStyle(srcPr.getStyleID())。); 布尔hasImage = FALSE; XWPFParagraph dstPr = destDoc.createParagraph(); //从源代码的docx文件中提取图像,并插入到目的地的docx文件。
为(XWPFRun srcRun:srcPr.getRuns()){ //当你想打电话XWPFParagraph.removeRun你需要下一个code()。
dstPr.createRun(); 如果(srcRun.getEmbeddedPictures()大小()方式> 0)
hasImage = TRUE; 对于(XWPFPicture图:srcRun.getEmbeddedPictures()){ 字节[] = IMG pic.getPictureData()的getData()。 长CX = pic.getCTPicture()getSpPr()getXfrm()getExt()getCx()。。
长CY = pic.getCTPicture()getSpPr()getXfrm()getExt()getCy()。。 尝试{
下面//工作给AddPicture code ...
字符串blipId = dstPr.getDocument()。addPictureData(新ByteArrayInputStream的(IMG)
Document.PICTURE_TYPE_PNG);
destDoc.createPictureCxCy(blipId,destDoc.getNextPicNameNumber(Document.PICTURE_TYPE_PNG)
CX,CY); }赶上(InvalidFormatException E1){
e1.printStackTrace();
}
}
} 如果(hasImage == FALSE)
{
。INT POS = destDoc.getParagraphs()尺寸() - 1;
destDoc.setParagraph(srcPr,POS)
} }否则如果(元素类型== BodyElementType.TABLE){ XWPFTable表=(XWPFTable)bodyElement; copyStyle(srcDoc,destDoc,srcDoc.getStyles()的getStyle(table.getStyleID())); destDoc.createTable(); 。INT POS = destDoc.getTables()尺寸() - 1; destDoc.setTable(POS,表);
}
} destDoc.write(出);
out.close();
} //表和段落的复制样式。
私有静态无效copyStyle(XWPFDocument srcDoc,XWPFDocument destDoc,XWPFStyle风格)
{
如果(destDoc == NULL ||风格== NULL)
返回; 如果(destDoc.getStyles()== NULL){
destDoc.createStyles();
} 清单< XWPFStyle> usedStyleList = srcDoc.getStyles()getUsedStyleList(风格)。
对于(XWPFStyle xwpfStyle:usedStyleList){
。destDoc.getStyles()addStyle(xwpfStyle);
}
} //复制页面布局。
//
//如果一个错误信息显示出来,下载OOXML-架构 - 1.1.jar文件,
//将它添加到类路径中。
//
// [错误]
//类型org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar
//不能得到解决。
//这是间接需要的.class文件中引用
//
//发生此错误的原因是在任何CTPageMar类
// POI-OOXML-架构 - 3.10.1-20140818.jar。
//
// [参考] http://poi.apache.org/faq.html#faq-N10025
// [参考] http://poi.apache.org/overview.html#components
//
//< OOXML-模式1.1下载>
// http://repo.maven.apache.org/maven2/org/apache/poi/ooxml-schemas/1.1/
//
私有静态无效copyLayout(XWPFDocument srcDoc,XWPFDocument destDoc)
{
CTPageMar pgMar = srcDoc.getDocument()getBody()getSectPr()getPgMar()。; BigInteger的底部= pgMar.getBottom();
BigInteger的页脚= pgMar.getFooter();
BigInteger的排水沟= pgMar.getGutter();
的BigInteger头= pgMar.getHeader();
BigInteger的左= pgMar.getLeft();
BigInteger的右= pgMar.getRight();
的BigInteger顶= pgMar.getTop(); CTPageMar addNewPgMar = destDoc.getDocument()getBody()addNewSectPr()addNewPgMar()。; addNewPgMar.setBottom(底);
addNewPgMar.setFooter(页脚);
addNewPgMar.setGutter(沟);
addNewPgMar.setHeader(头);
addNewPgMar.setLeft(左);
addNewPgMar.setRight(右);
addNewPgMar.setTop(顶部); CTPageSz pgSzSrc = srcDoc.getDocument()getBody()getSectPr()getPgSz()。; BigInteger的code = pgSzSrc.get code();
BigInteger的H = pgSzSrc.getH();
枚举东方= pgSzSrc.getOrient();
的BigInteger W = pgSzSrc.getW(); CTPageSz addNewPgSz = destDoc.getDocument()getBody()addNewSectPr()addNewPgSz()。; addNewPgSz.set code(code);
addNewPgSz.setH(H);
addNewPgSz.setOrient(东方);
addNewPgSz.setW(重量);
}
}
和CustomXWPFDocument类源。
包com.overflow.heeseok;进口java.io.IOException异常;进口org.apache.poi.xwpf.usermodel.XWPFDocument;
进口org.apache.xmlbeans *。
导入org.openxmlformats.schemas.drawingml.x2006.main *。
进口org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;/ **
* [参考] https://issues.apache.org/bugzilla/show_bug.cgi?id=49765
* [参考] http://pastebin.com/index/CbQ3iw8t,http://pastebin.com/2YAneYgt
* /
公共类CustomXWPFDocument扩展XWPFDocument
{
公共CustomXWPFDocument()抛出IOException异常
{
超();
} 公共无效createPictureCxCy(字符串blipId,INT ID,长CX,长CY)
{
CTInline内嵌= createParagraph()createRun()getCTR()addNewDrawing()addNewInline()。。 串picXml =+
< A:图形的xmlns:A = \\HTTP://schemas.openxmlformats.org/drawingml/2006/main \\>中+
< A:graphicData URI = \\HTTP://schemas.openxmlformats.org/drawingml/2006/picture \\>中+
<图片:图片的xmlns:PIC = \\HTTP://schemas.openxmlformats.org/drawingml/2006/picture \\>中+
< PIC:nvPicPr>中+
< PIC:cNvPr ID = \\+身份证+\\NAME = \\生成\\/>中+
< PIC:cNvPicPr />中+
< /图片:nvPicPr>中+
< PIC:blipFill>中+
< A:昙花一现R:嵌入= \\+ blipId +\\的xmlns:R = \\HTTP://schemas.openxmlformats.org/officeDocument/2006/relationships \\/>中+
< A:舒展>中+
< A:fillRect />中+
< / A:拉伸>中+
< /图片:blipFill>中+
< PIC:SPPR>中+
< A:XFRM>中+
< A:关闭x = \\0 \\Y = \\0 \\/>中+
< A:EXT CX = \\+ CX +\\CY = \\+ CY +\\/>中+
< / A:XFRM>中+
< A:prstGeom PRST = \\矩形\\>中+
< A:avLst />中+
< / A:prstGeom>中+
< /图片:SPPR>中+
< /图片:图片>中+
< / A:graphicData>中+
< / A:图形>中; // CTGraphicalObjectData graphicData = inline.addNewGraphic()addNewGraphicData()。
XmlToken xmlToken = NULL;
尝试
{
xmlToken = XmlToken.Factory.parse(picXml);
}
赶上(XmlException XE)
{
xe.printStackTrace();
}
inline.set(xmlToken);
//graphicData.set(xmlToken); inline.setDistT(0);
inline.setDistB(0);
inline.setDistL(0);
inline.setDistR(0); CTPositiveSize2D程度= inline.addNewExtent();
extent.setCx(CX);
extent.setCy(CY); CTNonVisualDrawingProps docPr = inline.addNewDocPr();
docPr.setId(ID);
docPr.setName(图片+身份证);
docPr.setDescr(生成);
} 公共无效createPicture(字符串blipId,INT ID,诠释的宽度,高度INT)
{
最终诠释动车组= 9525;
宽* =动车组;
高* =动车组;
//串blipId = getAllPictures()获得(ID).getPackageRelationship()的getId(); createPictureCxCy(blipId,编号,宽度,高度);
}
}
I am trying to copy the content from a particular paragraph in a .docx to another empty .docx .the problem i have is that the style,bullets,numbering etc from the source.docx is not retained in the destination .docx.Here is my code
can anyone please tell me what are the changes to be added to the above code?Thanks in Advance!!
public class WordFinal {
public static void main(String[] args) throws IOException, XmlException {
XWPFDocument doc = new XWPFDocument(new FileInputStream("source.docx"));
XWPFDocument destDoc =new XWPFDocument();
OutputStream out = new FileOutputStream("Destination.docx");
XWPFParagraph pr =doc.getParagraphs()[1];
String copy=pr.getText();
XWPFParagraph paragraphOne = destDoc.createParagraph();
XWPFRun paragraphOneRunOne = paragraphOne.createRun();
paragraphOneRunOne.setText(copy);
destDoc.write(out);
}
}
I'm using "poi-bin-3.10.1-20140818" library from http://poi.apache.org/
You can copy all paragraphs in the .docx file looping doc.getParagraphs().
But "Table" is not paragraph, so "Table" is not copied.
To copy "Table", you have to get IBodyElement and looping doc.getBodyElements().
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.xmlbeans.XmlException;
public class WordFinal {
public static void main(String[] args) throws IOException, XmlException {
XWPFDocument doc = new XWPFDocument(new FileInputStream("source.docx"));
XWPFDocument destDoc = new XWPFDocument();
OutputStream out = new FileOutputStream("Destination.docx");
// ** This code will copy just one paragraph. **
XWPFParagraph pr = doc.getParagraphs().get(0);
destDoc.createParagraph();
int pos = destDoc.getParagraphs().size() - 1;
destDoc.setParagraph(pr, pos);
destDoc.write(out);
}
}
So the code that copy all paragraphs and tables is like below.
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.xwpf.usermodel.BodyElementType;
import org.apache.poi.xwpf.usermodel.IBodyElement;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.xmlbeans.XmlException;
public class WordFinal {
public static void main(String[] args) throws IOException, XmlException {
XWPFDocument doc = new XWPFDocument(new FileInputStream("source.docx"));
XWPFDocument destDoc = new XWPFDocument();
OutputStream out = new FileOutputStream("Destination.docx");
for (IBodyElement bodyElement : doc.getBodyElements()) {
BodyElementType elementType = bodyElement.getElementType();
if (elementType.name().equals("PARAGRAPH")) {
XWPFParagraph pr = (XWPFParagraph) bodyElement;
destDoc.createParagraph();
int pos = destDoc.getParagraphs().size() - 1;
destDoc.setParagraph(pr, pos);
} else if( elementType.name().equals("TABLE") ) {
XWPFTable table = (XWPFTable) bodyElement;
destDoc.createTable();
int pos = destDoc.getTables().size() - 1;
destDoc.setTable(pos, table);
}
}
destDoc.write(out);
}
}
But even through this way, you can't copy image and style.
So copied document looks different with original document.
It seems that org.apache.poi.xwpf.usermodel.XWPFRun.addPicture() method has bug.
Docx document including image added by XWPFRun.addPicture() is not opened by Microsoft Word.
[ref.] https://issues.apache.org/bugzilla/show_bug.cgi?id=49765
Below code is including next functionality.
1) copy contents and styles of paragraphs and tables
2) copy page layout
3) copy images from source docx file
package com.overflow.heeseok;
import java.io.*;
import java.math.BigInteger;
import java.util.List;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STPageOrientation.Enum;
public class WordFinal {
public static void main(String[] args) throws IOException, XmlException
{
XWPFDocument srcDoc = new XWPFDocument(new FileInputStream("Source.docx"));
CustomXWPFDocument destDoc = new CustomXWPFDocument();
// Copy document layout.
copyLayout(srcDoc, destDoc);
OutputStream out = new FileOutputStream("Destination.docx");
for (IBodyElement bodyElement : srcDoc.getBodyElements()) {
BodyElementType elementType = bodyElement.getElementType();
if (elementType == BodyElementType.PARAGRAPH) {
XWPFParagraph srcPr = (XWPFParagraph) bodyElement;
copyStyle(srcDoc, destDoc, srcDoc.getStyles().getStyle(srcPr.getStyleID()));
boolean hasImage = false;
XWPFParagraph dstPr = destDoc.createParagraph();
// Extract image from source docx file and insert into destination docx file.
for (XWPFRun srcRun : srcPr.getRuns()) {
// You need next code when you want to call XWPFParagraph.removeRun().
dstPr.createRun();
if (srcRun.getEmbeddedPictures().size() > 0)
hasImage = true;
for (XWPFPicture pic : srcRun.getEmbeddedPictures()) {
byte[] img = pic.getPictureData().getData();
long cx = pic.getCTPicture().getSpPr().getXfrm().getExt().getCx();
long cy = pic.getCTPicture().getSpPr().getXfrm().getExt().getCy();
try {
// Working addPicture Code below...
String blipId = dstPr.getDocument().addPictureData(new ByteArrayInputStream(img),
Document.PICTURE_TYPE_PNG);
destDoc.createPictureCxCy(blipId, destDoc.getNextPicNameNumber(Document.PICTURE_TYPE_PNG),
cx, cy);
} catch (InvalidFormatException e1) {
e1.printStackTrace();
}
}
}
if (hasImage == false)
{
int pos = destDoc.getParagraphs().size() - 1;
destDoc.setParagraph(srcPr, pos);
}
} else if (elementType == BodyElementType.TABLE) {
XWPFTable table = (XWPFTable) bodyElement;
copyStyle(srcDoc, destDoc, srcDoc.getStyles().getStyle(table.getStyleID()));
destDoc.createTable();
int pos = destDoc.getTables().size() - 1;
destDoc.setTable(pos, table);
}
}
destDoc.write(out);
out.close();
}
// Copy Styles of Table and Paragraph.
private static void copyStyle(XWPFDocument srcDoc, XWPFDocument destDoc, XWPFStyle style)
{
if (destDoc == null || style == null)
return;
if (destDoc.getStyles() == null) {
destDoc.createStyles();
}
List<XWPFStyle> usedStyleList = srcDoc.getStyles().getUsedStyleList(style);
for (XWPFStyle xwpfStyle : usedStyleList) {
destDoc.getStyles().addStyle(xwpfStyle);
}
}
// Copy Page Layout.
//
// if next error message shows up, download "ooxml-schemas-1.1.jar" file and
// add it to classpath.
//
// [Error]
// The type org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar
// cannot be resolved.
// It is indirectly referenced from required .class files
//
// This error happens because there is no CTPageMar class in
// poi-ooxml-schemas-3.10.1-20140818.jar.
//
// [ref.] http://poi.apache.org/faq.html#faq-N10025
// [ref.] http://poi.apache.org/overview.html#components
//
// < ooxml-schemas 1.1 download >
// http://repo.maven.apache.org/maven2/org/apache/poi/ooxml-schemas/1.1/
//
private static void copyLayout(XWPFDocument srcDoc, XWPFDocument destDoc)
{
CTPageMar pgMar = srcDoc.getDocument().getBody().getSectPr().getPgMar();
BigInteger bottom = pgMar.getBottom();
BigInteger footer = pgMar.getFooter();
BigInteger gutter = pgMar.getGutter();
BigInteger header = pgMar.getHeader();
BigInteger left = pgMar.getLeft();
BigInteger right = pgMar.getRight();
BigInteger top = pgMar.getTop();
CTPageMar addNewPgMar = destDoc.getDocument().getBody().addNewSectPr().addNewPgMar();
addNewPgMar.setBottom(bottom);
addNewPgMar.setFooter(footer);
addNewPgMar.setGutter(gutter);
addNewPgMar.setHeader(header);
addNewPgMar.setLeft(left);
addNewPgMar.setRight(right);
addNewPgMar.setTop(top);
CTPageSz pgSzSrc = srcDoc.getDocument().getBody().getSectPr().getPgSz();
BigInteger code = pgSzSrc.getCode();
BigInteger h = pgSzSrc.getH();
Enum orient = pgSzSrc.getOrient();
BigInteger w = pgSzSrc.getW();
CTPageSz addNewPgSz = destDoc.getDocument().getBody().addNewSectPr().addNewPgSz();
addNewPgSz.setCode(code);
addNewPgSz.setH(h);
addNewPgSz.setOrient(orient);
addNewPgSz.setW(w);
}
}
And CustomXWPFDocument class source.
package com.overflow.heeseok;
import java.io.IOException;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.xmlbeans.*;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
/**
* [ref] https://issues.apache.org/bugzilla/show_bug.cgi?id=49765
* [ref] http://pastebin.com/index/CbQ3iw8t, http://pastebin.com/2YAneYgt
*/
public class CustomXWPFDocument extends XWPFDocument
{
public CustomXWPFDocument() throws IOException
{
super();
}
public void createPictureCxCy(String blipId,int id, long cx, long cy)
{
CTInline inline = createParagraph().createRun().getCTR().addNewDrawing().addNewInline();
String picXml = "" +
"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">" +
" <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">" +
" <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">" +
" <pic:nvPicPr>" +
" <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>" +
" <pic:cNvPicPr/>" +
" </pic:nvPicPr>" +
" <pic:blipFill>" +
" <a:blip r:embed=\"" + blipId + "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>" +
" <a:stretch>" +
" <a:fillRect/>" +
" </a:stretch>" +
" </pic:blipFill>" +
" <pic:spPr>" +
" <a:xfrm>" +
" <a:off x=\"0\" y=\"0\"/>" +
" <a:ext cx=\"" + cx + "\" cy=\"" + cy + "\"/>" +
" </a:xfrm>" +
" <a:prstGeom prst=\"rect\">" +
" <a:avLst/>" +
" </a:prstGeom>" +
" </pic:spPr>" +
" </pic:pic>" +
" </a:graphicData>" +
"</a:graphic>";
//CTGraphicalObjectData graphicData = inline.addNewGraphic().addNewGraphicData();
XmlToken xmlToken = null;
try
{
xmlToken = XmlToken.Factory.parse(picXml);
}
catch(XmlException xe)
{
xe.printStackTrace();
}
inline.set(xmlToken);
//graphicData.set(xmlToken);
inline.setDistT(0);
inline.setDistB(0);
inline.setDistL(0);
inline.setDistR(0);
CTPositiveSize2D extent = inline.addNewExtent();
extent.setCx(cx);
extent.setCy(cy);
CTNonVisualDrawingProps docPr = inline.addNewDocPr();
docPr.setId(id);
docPr.setName("Picture " + id);
docPr.setDescr("Generated");
}
public void createPicture(String blipId,int id, int width, int height)
{
final int EMU = 9525;
width *= EMU;
height *= EMU;
//String blipId = getAllPictures().get(id).getPackageRelationship().getId();
createPictureCxCy(blipId, id, width, height);
}
}
这篇关于如何.DOCX的一个段落复制到另一个.DOCX withJava并保留风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!