本文目錄一覽:
- 1、高分求:網頁生成印章~~~
- 2、怎樣用JAVA實現電子印章?
- 3、Java或js實現動態生成橢圓電子章圖片(非窗體程序)
- 4、怎樣用軟體製作一個印章印出來的圖案?圓形的那種?
- 5、怎樣用JAVA實現電子印章
高分求:網頁生成印章~~~
在網頁上生成一個章
1、你參考一下,
該處有原代碼!
2、你再看看
該處有附件,試著做一下!
3、你也可以看看:
然後你打開該網頁的源文件,參考一下,是不是也有靈感了!
其中核心部分代碼為:
//………………………………………//
function checkform(thisform){
var re;
var val;
val=thisform.showname.value;
if (val.length != 4)
{
alert(“請輸入您的印章文字,格式為4個漢字!”);
thisform.showname.focus();
return false;
}
if (!strChina(val)){
alert(“請輸入您的印章文字,格式為4個漢字!”);
thisform.showname.focus();
return false;
}
/*val=eval(‘thisform.imgtype’);
if (!val[0].checked !val[1].checked){
alert(“請選擇印章的類型!”);
val[0].focus();
return false;
}*/
val=eval(‘thisform.fontname’);
if (!val[0].checked !val[1].checked !val[2].checked !val[3].checked !val[4].checked !val[5].checked){
alert(“請選擇印章文字的字體!”);
val[0].focus();
return false;
}
return true;
}
function strChina(astr){
var lst = /[u00-uFF]/;
return !lst.test(astr);
}
//………………………………………….//
最後祝你成功!
怎樣用JAVA實現電子印章?
參考如下代碼:
package com.wonders.cop.billing.util;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.imageio.ImageIO;
public class ImageMarkLogoUtil {
// 水印透明度
private static float alpha = 1f;
// 水印橫向位置
private static int positionWidth = 82;
// 水印縱向位置
private static int positionHeight = 545;
// 水印文字字體
private static Font font = new Font(“宋體”, Font.PLAIN, 13);
// 水印文字顏色
private static Color color = Color.black;
public static void main(String[] args) {
String srcImgPath = “d:/888880002302900_web.jpg”;
String targerTextPath = “d:/qie_text.jpg”;
ImageMarkLogoUtil
.markImageByTexts(testValue(),
BillDetailImagePosition.getPosition(“888880002302900”), srcImgPath,
targerTextPath);
}
public static Map testValue() {
MapString, String value = new HashMapString, String();
value.put(“feedPrice”, “15.1”);
value.put(“feedCount”, “20”);
value.put(“nowNum”, “124”);
value.put(“drainageCount”, “55”);
value.put(“drainagePrice”, “1.5”);
value.put(“feedCost”, “66”);
value.put(“cost”, “66”);
value.put(“drainageCost”, “100”);
value.put(“barcode”, “10101010101010101”);
value.put(“nextCopy”, “2014-12-10”);
value.put(“waterType”, “居民生活用水”);
value.put(“meterReader”, “測試人員”);
value.put(“copyNumber”, “741sg”);
value.put(“prevCarryOver”, “0.25”);
value.put(“nowCarryOver”, “2.12”);
value.put(“openDate”, “20141002”);
value.put(“nextMonth”, “201402 “);
value.put(“remark”, “您繳付的2013年03月30.80元水費,我公司已收到,謝謝!”);
value.put(“detailStatus”, “00”);
value.put(“billStatus”, “00”);
value.put(“prevMonth”, “201406”);
value.put(“lastPayDate”, “20140112”);
value.put(“companyName”, “市北水”);
value.put(“type”, “1”);
value.put(“amount”, “58.1”);
value.put(“address”, “浦秀路220弄10號101”);
value.put(“year”,”2014″);
value.put(“month”, “04”);
value.put(“billId”, “11111”);
value.put(“account”, “38445450”);
value.put(“companyId”, “888880002302900”);
value.put(“realName”, “姚航”);
return value;
}
/**
* 給圖片添加水印文字、可設置水印文字的旋轉角度
*
* @param logoText
* @param srcImgPath
* @param targerPath
* @param degree
*/
public static void markImageByTexts(MapString, String value,
MapString, String[] position, String srcImgPath, String targerPath) {
InputStream is = null;
OutputStream os = null;
try {
// 1、源圖片
Image srcImg = ImageIO.read(new File(srcImgPath));
BufferedImage buffImg = new BufferedImage(srcImg.getWidth(null),
srcImg.getHeight(null), BufferedImage.TYPE_INT_RGB);
// 2、得到畫筆對象
IteratorString positionIter = position.keySet().iterator();
String key = “”;
String logotext = “”;
String[] xy;
while (positionIter.hasNext()) {
key = positionIter.next();
xy = position.get(key);
logotext = value.get(key);
System.out.println(“key:”+key+”,value:”+logotext);
if (xy != null xy.length == 2)
printText(srcImg, buffImg, logotext,
Integer.valueOf(xy[0]), Integer.valueOf(xy[1]));
}
// 10、生成圖片
os = new FileOutputStream(targerPath);
ImageIO.write(buffImg, “JPG”, os);
System.out.println(“圖片完成添加水印文字”);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is)
is.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
if (null != os)
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 在圖片上列印文字
*
* @param srcImg
* @param buffImg
* @param logoText
* @return
*/
private static void printText(Image srcImg, BufferedImage buffImg,
String logoText, Integer positionX, Integer PositionY) {
Graphics2D g = buffImg.createGraphics();
// 3、設置對線段的鋸齒狀邊緣處理
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(
srcImg.getScaledInstance(srcImg.getWidth(null),
srcImg.getHeight(null), Image.SCALE_SMOOTH), 0, 0, null);
// 5、設置水印文字顏色
g.setColor(color);
// 6、設置水印文字Font
g.setFont(font);
// 7、設置水印文字透明度
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
alpha));
// 8、第一參數-設置的內容,後面兩個參數-文字在圖片上的坐標位置(x,y)
g.drawString(logoText, positionX, PositionY);
// 9、釋放資源
g.dispose();
}
}
Java或js實現動態生成橢圓電子章圖片(非窗體程序)
現成寫好的印章生成小工具源碼,還支持橢圓、私章等。直通車:
怎樣用軟體製作一個印章印出來的圖案?圓形的那種?
我用的是Adobe Photoshop CS。如果老兄會用這個軟體的話應該不難,做一個圓形外框很簡單,主要是裡面的文字,這要用路徑工具。用圓形選框工具畫一選區,點路徑下面的建立路徑,點文字工具,將游標點中剛建立的路徑(也就是你需要的文字起始位置)輸入需 要的文字。文字大小、間距都可調,當然也可以根據文字調整圓圈的大小使之相合適,至於中間的五角星,我想只要會Photoshop 就不難做了
怎樣用JAVA實現電子印章
參考如下代碼
package com.wonders.cop.billing.util;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.imageio.ImageIO;
public class ImageMarkLogoUtil {
// 水印透明度
private static float alpha = 1f;
// 水印橫向位置
private static int positionWidth = 82;
// 水印縱向位置
private static int positionHeight = 545;
// 水印文字字體
private static Font font = new Font(“宋體”, Font.PLAIN, 13);
// 水印文字顏色
private static Color color = Color.black;
public static void main(String[] args) {
String srcImgPath = “d:/888880002302900_web.jpg”;
String targerTextPath = “d:/qie_text.jpg”;
ImageMarkLogoUtil
.markImageByTexts(testValue(),
BillDetailImagePosition.getPosition(“888880002302900”), srcImgPath,
targerTextPath);
}
public static Map testValue() {
MapString, String value = new HashMapString, String();
value.put(“feedPrice”, “15.1”);
value.put(“feedCount”, “20”);
value.put(“nowNum”, “124”);
value.put(“drainageCount”, “55”);
value.put(“drainagePrice”, “1.5”);
value.put(“feedCost”, “66”);
value.put(“cost”, “66”);
value.put(“drainageCost”, “100”);
value.put(“barcode”, “10101010101010101”);
value.put(“nextCopy”, “2014-12-10”);
value.put(“waterType”, “居民生活用水”);
value.put(“meterReader”, “測試人員”);
value.put(“copyNumber”, “741sg”);
value.put(“prevCarryOver”, “0.25”);
value.put(“nowCarryOver”, “2.12”);
value.put(“openDate”, “20141002”);
value.put(“nextMonth”, “201402 “);
value.put(“remark”, “您繳付的2013年03月30.80元水費,我公司已收到,謝謝!”);
value.put(“detailStatus”, “00”);
value.put(“billStatus”, “00”);
value.put(“prevMonth”, “201406”);
value.put(“lastPayDate”, “20140112”);
value.put(“companyName”, “市北水”);
value.put(“type”, “1”);
value.put(“amount”, “58.1”);
value.put(“address”, “浦秀路220弄10號101”);
value.put(“year”,”2014″);
value.put(“month”, “04”);
value.put(“billId”, “11111”);
value.put(“account”, “38445450”);
value.put(“companyId”, “888880002302900”);
value.put(“realName”, “姚航”);
return value;
}
/**
* 給圖片添加水印文字、可設置水印文字的旋轉角度
*
* @param logoText
* @param srcImgPath
* @param targerPath
* @param degree
*/
public static void markImageByTexts(MapString, String value,
MapString, String[] position, String srcImgPath, String targerPath) {
InputStream is = null;
OutputStream os = null;
try {
// 1、源圖片
Image srcImg = ImageIO.read(new File(srcImgPath));
BufferedImage buffImg = new BufferedImage(srcImg.getWidth(null),
srcImg.getHeight(null), BufferedImage.TYPE_INT_RGB);
// 2、得到畫筆對象
IteratorString positionIter = position.keySet().iterator();
String key = “”;
String logotext = “”;
String[] xy;
while (positionIter.hasNext()) {
key = positionIter.next();
xy = position.get(key);
logotext = value.get(key);
System.out.println(“key:”+key+”,value:”+logotext);
if (xy != null xy.length == 2)
printText(srcImg, buffImg, logotext,
Integer.valueOf(xy[0]), Integer.valueOf(xy[1]));
}
// 10、生成圖片
os = new FileOutputStream(targerPath);
ImageIO.write(buffImg, “JPG”, os);
System.out.println(“圖片完成添加水印文字”);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is)
is.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
if (null != os)
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 在圖片上列印文字
*
* @param srcImg
* @param buffImg
* @param logoText
* @return
*/
private static void printText(Image srcImg, BufferedImage buffImg,
String logoText, Integer positionX, Integer PositionY) {
Graphics2D g = buffImg.createGraphics();
// 3、設置對線段的鋸齒狀邊緣處理
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(
srcImg.getScaledInstance(srcImg.getWidth(null),
srcImg.getHeight(null), Image.SCALE_SMOOTH), 0, 0, null);
// 5、設置水印文字顏色
g.setColor(color);
// 6、設置水印文字Font
g.setFont(font);
// 7、設置水印文字透明度
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
alpha));
// 8、第一參數-設置的內容,後面兩個參數-文字在圖片上的坐標位置(x,y)
g.drawString(logoText, positionX, PositionY);
// 9、釋放資源
g.dispose();
}
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/296274.html