(例)Java生成PDF图片 iText
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.pdf.PdfEncryption;
public class testIText extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
try{
//设置图片大小 页面为A4
Document document = new Document(PageSize.A4, 110, 110, 120, 140);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, bos);
//1,设置此PDF文件的权限,只有写上的是允许的。这里只允许打印,读取和保存,不允许修改等。
int intPermissions = PdfWriter.AllowPrinting |PdfWriter.AllowScreenReaders;
//2,若要实现其他权限如修改等 则需要写入密码,这里是设置密码加密标准或加密类型。
int intEncryptionType = PdfEncryption.STANDARD_ENCRYPTION_40;
//3,要是用这个方法需要引入一个jar包(bcprov-jdk15-137.jar)。第一个参数:打开时需要的密码;第二个参数:实用其
相关文档:
由于有个合作项目,用到了REST,我们这边的服务器是java的,合作方那边主要是PHP环境,为了远程调用的问题,使用了REST作为API的实现方
案。现在项目做得差不多了,下面记下自己的一点心得,算是笔记吧。
REST(Representational State Transfer)的说法来自“Architectural Styles and the Desi ......
/*
* GetMacAddress .java
*
* description:get Mac addreess
*
* @author hadeslee
*
* Created on 2007-9-27, 9:11:15
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test2;
import java.io.BufferedReader;
import java.io.IO ......
学习之路总是并不平坦的,这不,一开始就遇到问题了:Bad version number in .class file。版本不对?可是我用的java以及javac都是JDK5呀,怎么回事?除了编译版本跟运行版本不一致外是不会出现这种可能的。突然想起前几天试了一下JDK6,把Eclipse的JDK编译器选成JDK6了。果然,将其改回去JDK5就行了。
================== ......
某知名门户网站的一道笔试题
public class Test {
public static void stringUpd(String str) {
str = str.replace("j", "l");
System.out.println(str);
}
public static void stringBufferUpd(StringBuffer bf) {
bf.append("c");
System.out.println(bf);
}
......