1. 如何使用Aspose Words for Java插入条形图
虽然Aspose.Words for Java目前还不允许在Word文档中创建条形图。但是可以通过Aspose.Cells for Java创建静态条形图,并选染成图片,然后再通过Aspose.Words for Java添加到Word文档中:
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
//Set the name of worksheet
sheet.setName("Data");
//Get the cells collection in the sheet.
Cells cells = workbook.getWorksheets().get(0).getCells();
//Put some values into a cells of the Data sheet.
cells.get("A1").setValue("Region");
cells.get("A2").setValue("France");
cells.get("A3").setValue("Germany");
cells.get("A4").setValue("England");
2. 用aspose.word 如何设置背景图片
方法是可行的,不过要2次IO操作了~
另外也可以存成流形式,再调整大小保存:
Document doc = new Document(Server.MapPath("~/test.doc"));
using (Stream stream = new MemoryStream())
{
doc.Save(stream, SaveFormat.Jpeg);
using (System.Drawing.Image image = Bitmap.FromStream(stream)) // 原始图
{
using (Bitmap image2 = new Bitmap(image, 400, 300))
{
image2.Save(Server.MapPath("~/test.jpg"));
}
}
}
3. asposewords可以插入上标或下标吗
可以的,官网就有例子
我自己写了一个Demo
Document doc = new Document();
Section section = new Section(doc);
doc.AppendChild(section);
Body body = new Body(doc);
section.AppendChild(body);
Paragraph para = new Paragraph(doc);
body.AppendChild(para);
Run run = new Run(doc);
run.Text = "Hello World";
run.Font.Color = Color.Red;
run.Font.Size = 20F;
para.AppendChild(run);
Run r = new Run(doc);
r.Text = "100";
//变成上标
r.Font.Superscript = true;
para.AppendChild(r);
Run srun = new Run(doc);
srun.Text = "200";
//变成下标
srun.Font.Subscript = true;
para.AppendChild(srun);
doc.Save("D://test.doc", SaveFormat.Doc);效果如下图:
4. aspose.word 把Word转成图片时,格式变了
Aspose.PDF无法直接转换word文档,需要先有个中间步骤。就是先把word转换成XML格式的文件,再使用Aspose.PDF绑定这个XML,再保存为PDF格式。如果word文档中有图片,则生成XML的时候会在临时文件夹中生成图片。
调整word图片位置方法如下:
1、打开一个word文档,插入一副图片;
2、要想随意调整图片,就要先来设置图片格式,在图片上点右键,选中“设置图片格式”;
3、在弹出的对话框中选择“文字环绕”,“浮于文字上方”,确认之后,就可以随意移动图片位置了,当然相应的文字位置也要根据需要调整。
转载请注明出处51数据库 » aspose.words插入