通过 PDFRenderer 实现预览PDF 功能

本文介绍了如何利用PDFRenderer库实现PDF文件的预览功能,适合零基础的读者学习。同时,鼓励分享知识,促进技术交流,为中华文化的复兴贡献力量。
摘要由CSDN通过智能技术生成

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

                需要一个jar PDFRenderer-0.9.0.jar 

http://java.net/downloads/pdf-renderer/PDFRenderer-0.9.0.jar 


package com.wonders.stpt.attach.action;import java.awt.Image;import java.awt.Rectangle;import java.awt.image.BufferedImage;import java.io.File;import java.io.FileInputStream;import java.io.FilenameFilter;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.io.RandomAccessFile;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;import java.util.Arrays;import java.util.Comparator;import javax.imageio.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Namespace;import org.apache.struts2.convention.annotation.ParentPackage;import org.apache.struts2.convention.annotation.Result;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Component;import com.sun.image.codec.jpeg.JPEGCodec;import com.sun.image.codec.jpeg.JPEGImageEncoder;import com.sun.pdfview.PDFFile;import com.sun.pdfview.PDFPage;import com.wonders.stpt.attach.model.vo.UploadFile;import com.wonders.stpt.attach.service.FjshService;import com.wonders.stpt.userMsg.action.AbstractParamAction;@SuppressWarnings("serial")@ParentPackage("struts-default")@Namespace(value="/attach")@Component("attachViewerAction")@Scope("prototype")public class AttachViewerAction extends AbstractParamAction{  private FjshService fjshService; private final int maxPage = 30;   public FjshService getFjshService() {  return fjshService; }  @Autowired(required=falsepublic void setFjshService(@Qualifier("fjshService")FjshService fjshService) {  this.fjshService = fjshService; }  /**  * PDF文档在线以图片格式预览.  *   */
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值