我想在上传WORD文件的时候给上传的word文件加水印,该如何实现?

liujian098 2009-08-19 09:53:06
我想在上传WORD文件的时候给上传的word文件加水印,该如何实现?

能给代码吗?
...全文
592 25 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujian098 2009-08-26
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复
路过学习!
liujian098 2009-08-25
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 ximengchang 的回复:]
恩,几位大虾的做法都不错,可以参考
[/Quote]
没转asp的啊
liujian098 2009-08-25
  • 打赏
  • 举报
回复
顶起来啊
月光下的土豆 2009-08-24
  • 打赏
  • 举报
回复
有空看看
liujian098 2009-08-24
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 tidelgl 的回复:]
比较牛X的想法!
[/Quote]

既然C#
能实现,asp应该也行吧?
tidelgl 2009-08-24
  • 打赏
  • 举报
回复
比较牛X的想法!
liujian098 2009-08-24
  • 打赏
  • 举报
回复
mark
ximengchang 2009-08-24
  • 打赏
  • 举报
回复
恩,几位大虾的做法都不错,可以参考
chinank 2009-08-21
  • 打赏
  • 举报
回复
学习
zjj010 2009-08-21
  • 打赏
  • 举报
回复
我也想知道
liujian098 2009-08-21
  • 打赏
  • 举报
回复
ding
xb520hh 2009-08-20
  • 打赏
  • 举报
回复
谁能帮忙写一个asp和php的
谢谢
liujian098 2009-08-20
  • 打赏
  • 举报
回复
顶起来
liujian098 2009-08-20
  • 打赏
  • 举报
回复
mark
凡夫与俗子 2009-08-19
  • 打赏
  • 举报
回复
帮顶下
liujian098 2009-08-19
  • 打赏
  • 举报
回复
谁能帮写个asp的啊????
感谢啊
fztjava 2009-08-19
  • 打赏
  • 举报
回复
public final class ImageUtils {
public ImageUtils() {

}

/**
* 把图片印刷到图片上
*
* @param pressImg --
* 水印文件
* @param targetImg --
* 目标文件
* @param x
* @param y
*/
public final static void pressImage(String pressImg, String targetImg,
int x, int y) {
try {
File _file = new File(targetImg);
Image src = ImageIO.read(_file);
int wideth = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(wideth, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.drawImage(src, 0, 0, wideth, height, null);

// 水印文件
File _filebiao = new File(pressImg);
Image src_biao = ImageIO.read(_filebiao);
int wideth_biao = src_biao.getWidth(null);
int height_biao = src_biao.getHeight(null);
g.drawImage(src_biao, wideth - wideth_biao - x, height
- height_biao - y, wideth_biao, height_biao, null);
// /
g.dispose();
FileOutputStream out = new FileOutputStream(targetImg);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(image);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* 打印文字水印图片
*
* @param pressText
* --文字
* @param targetImg --
* 目标图片
* @param fontName --
* 字体名
* @param fontStyle --
* 字体样式
* @param color --
* 字体颜色
* @param fontSize --
* 字体大小
* @param x --
* 偏移量
* @param y
*/

public static void pressText(String pressText, String targetImg,
String fontName, int fontStyle, int color, int fontSize, int x,
int y) {
try {
File _file = new File(targetImg);
Image src = ImageIO.read(_file);
int wideth = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(wideth, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.drawImage(src, 0, 0, wideth, height, null);
// String s="www.qhd.com.cn";
g.setColor(Color.RED);
g.setFont(new Font(fontName, fontStyle, fontSize));

g.drawString(pressText, wideth - fontSize - x, height - fontSize
/ 2 - y);
g.dispose();
FileOutputStream out = new FileOutputStream(targetImg);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(image);
out.close();
} catch (Exception e) {
System.out.println(e);
}
}

public static void main(String[] args) {
pressImage("E:\\C\\cc\\a.jpg", "E:\\C\\cc\\a.jpg", 20, 20);
}
}
mailbao 2009-08-19
  • 打赏
  • 举报
回复
轉載>> asp實現對word文件加水印的方法

---------------------------------------

請參考 http://hi.baidu.com/shishuchang/blog/item/a376df24b7238c004d088d66.html
mailbao 2009-08-19
  • 打赏
  • 举报
回复
asp代碼:沒研究過,不過可以參考C#代碼的開發思路,即:
--------------------------------------------

/**////1.初始化文档对象
Word.Document WordDoc= wordAppObj.Documents.Open(ref _filename, ref missing, ref isReadOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
/**////2.根据文档对象的高度与宽度生成文档背景的图片
string bkpic = CreateBackGroup(WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, picFilePath);
Word.Shape oShape;
/**////3.创建背景水印图征
WordDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
WordDoc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter("");
object top = 30;
/**////4.将背景水印图片插入到Word
oShape = WordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(bkpic, ref missing, ref missing, ref missing, ref top, ref missing, ref missing, ref missing);
oShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;
oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);


-------------------------------------------------------------


C#代碼:(供參考)

http://topic.csdn.net/u/20090331/08/6fb8a41b-8d22-43ad-96d1-468b8e97a6ba.html
加载更多回复(5)

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧