java 生成海报-java中怎么将word文档怎么生成图片
java自定义字体文字和图片生成新图片(高分)

这个技术好实现,思想如下:
用js控制;
再根据文字与形式生成图片;
再输出即可。
我以前做过。
java中怎么将word文档怎么生成图片

public class CreateWordDemo
{
public void createDocContext(String file)
throws DocumentException,IOException {
//
设置纸张大小
Document document = new
Document(PageSize.A4);
//
建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中
(document, new
FileOutputStream(file));
();
//
设置中文字体
BaseFont bfChinese =
("STSongStd-Light", "UniGB-UCS2-H",
_EMBEDDED);
//
标题字体风格
Font titleFont = new Font(bfChinese, 12,
);
//
正文字体风格
Font contextFont = new Font(bfChinese, 10,
);
Paragraph title = new
Paragraph("标题");
//
设置标题格式对齐方式
(_CENTER);
(titleFont);
(title);
String contextString =
"iText是一个能够快速产生PDF文件的java类库。"
+ " \n"//
换行
+
"iText的java类对于那些要产生包含文本,"
+ "表格,图形的只读文档是很有用的。它的类库尤其与java
Servlet有很好的给合。"
+
"使用iText与PDF能够使你正确的控制Servlet的输出。";
Paragraph context = new
Paragraph(contextString);
//
正文格式左对齐
(_LEFT);
(contextFont);
//
离上一段落(标题)空的行数
(5);
//
设置第一行空的列数
(20);
(context);
//
利用类FontFactory结合Font和Color可以设置各种各样字体样式
Paragraph underline = new Paragraph("下划线的实现",
(
_BOLDOBLIQUE, 18,
, new Color(0, 0,
255)));
(underline);
// 设置 Table
表格
Table aTable = new
Table(3);
int width[] = { 25, 25, 50
};
(width);//
设置每列所占比例
(90); // 占页面宽度
90%
(_CENTER);//
居中显示
(_MIDDLE);//
纵向居中显示
(true); //
自动填满
(1); //
边框宽度
(new Color(0, 125, 255)); //
边框颜色
(2);//
衬距,看效果就知道什么意思了
(3);//
即单元格之间的间距
(2);//
边框
//
设置表头
Cell haderCell = new
Cell("表格表头");
(true);
(3);
(haderCell);
();
Font fontChinese = new Font(bfChinese, 12, ,
);
Cell cell = new Cell(new Phrase("这是一个测试的 3*3 Table 数据",
fontChinese));
(_TOP);
(new Color(255, 0,
0));
(2);
(cell);
(new
Cell("#1"));
(new
Cell("#2"));
(new
Cell("#3"));
(new
Cell("#4"));
Cell cell3 = new Cell(new Phrase("一行三列数据",
fontChinese));
(3);
(_CENTER);
(cell3);
(aTable);
(new
Paragraph("\n"));
//
添加图片 即可以放路径又可以放二进制字节流
Image img =
("d:\\");
(0,
0);
();//
设置图片显示位置
(60, 60);//
直接设定显示尺寸
//
(50);//表示显示的大小为原尺寸的50%
// (25,
12);//图像高宽的显示比例
//
(30);//图像旋转一定角度
(img);
();
}
public static void main(String[] args)
{
CreateWordDemo word = new
CreateWordDemo();
String file =
"d:/";
try
{
(file);
} catch (DocumentException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
java生成jpg图片 并且实现文字和图片混排

import ;
import ;
import ;
import ;
import ;
import .*;
import ;
public class ChartGraphics {
BufferedImage image;
void createImage(String fileLocation) {
try {
FileOutputStream fos = new FileOutputStream(fileLocation);
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = (bos);
(image);
();
} catch (Exception e) {
e.printStackTrace();
}
}
public void graphicsGeneration(String name, String id, String classname, String imgurl) {
int imageWidth = 500;//图片的宽度
int imageHeight = 400;//图片的高度
image = new BufferedImage(imageWidth, imageHeight, _INT_RGB);
Graphics graphics = ();
();
(0, 0, imageWidth, imageHeight);
();
("姓名 : " + name, 50, 75);
("学号 : " + id, 50, 150);
("班级 : " + classname, 50, 225);
//ImageIcon imageIcon = new ImageIcon(imgurl);
//((), 230, 0, null);
//改成这样:
BufferedImage bimg = null;
try {
bimg = (new (imgurl));
} catch (Exception e) {}
if(bimg!=null)
(bimg, 230, 0, null);
();
createImage("G:\\TDDOWNLOAD\\");
}
public static void main(String[] args) {
ChartGraphics cg = new ChartGraphics();
try {
("ewew", "1", "12", "C:/Documents and Settings/Administrator/My Documents/My Pictures/7.jpg");
} catch (Exception e) {
e.printStackTrace();
}
}
}
-
果盘绘画图片大全简单创作方法快速制作技巧2024-01-02 16:57:54
-
小年插画图片创作方法快速制作技巧2024-01-02 16:57:20
-
小年绘画作品制作技巧2024-01-02 16:55:45
-
小年插画图片创作方法快速制作技巧2024-01-02 16:55:02
-
立春插画图片如何制作2024-01-02 16:54:19
-
立春插画图片创作方法快速制作技巧2024-01-02 16:53:32






扫描二维码添加客服微信
扫描二维码关注