我有PDF的,问题是看你的悬赏分数有多高,我们大家也都很忙的
Java网络编程技术与实践
作者:杜佳荣,马建红,腾振宇
出版社:清华大学出版社 2008年
页数: 556
‘贰’ java 如何读取PDF文件内容
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;
public class PdfReader {
public void readFdf(String file) throws Exception {
// 是否排序
boolean sort = false;
// pdf文件名
String pdfFile = file;
// 输入文本文件名称
String textFile = null;
// 编码方式
String encoding = "UTF-8";
// 开始提取页数
int startPage = 1;
// 结束提取页数
int endPage = Integer.MAX_VALUE;
// 文件输入流,生成文本文件
Writer output = null;
// 内存中存储的PDF Document
PDDocument document = null;
try {
try {
// 首先当作一个URL来装载文件,如果得到异常再从本地文件系统//去装载文件
URL url = new URL(pdfFile);
//注意参数已不是以前版本中的URL.而是File。
document = PDDocument.load(pdfFile);
// 获取PDF的文件名
String fileName = url.getFile();
// 以原来PDF的名称来命名新产生的txt文件
if (fileName.length() > 4) {
File outputFile = new File(fileName.substring(0, fileName
.length() - 4)
+ ".txt");
textFile = outputFile.getName();
}
} catch (MalformedURLException e) {
// 如果作为URL装载得到异常则从文件系统装载
//注意参数已不是以前版本中的URL.而是File。
document = PDDocument.load(pdfFile);
if (pdfFile.length() > 4) {
textFile = pdfFile.substring(0, pdfFile.length() - 4)
+ ".txt";
}
}
// 文件输入流,写入文件倒textFile
output = new OutputStreamWriter(new FileOutputStream(textFile),
encoding);
// PDFTextStripper来提取文本
PDFTextStripper stripper = null;
stripper = new PDFTextStripper();
// 设置是否排序
stripper.setSortByPosition(sort);
// 设置起始页
stripper.setStartPage(startPage);
// 设置结束页
stripper.setEndPage(endPage);
// 调用PDFTextStripper的writeText提取并输出文本
stripper.writeText(document, output);
} finally {
if (output != null) {
// 关闭输出流
output.close();
}
if (document != null) {
// 关闭PDF Document
document.close();
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
PdfReader pdfReader = new PdfReader();
try {
// 取得E盘下的SpringGuide.pdf的内容
pdfReader.readFdf("E://SpringGuide.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
‘叁’ 《Java网络编程核心技术详解》pdf下载在线阅读全文,求百度网盘云资源
《Java网络编程核心技术详解》网络网盘pdf最新全集下载:
链接: https://pan..com/s/1_XTd5UzNdDfNK3oN7lcUYQ
‘肆’ java怎样将网页上面的数据以pdf的格式导出,求代码
需要用到一个pdf的jar包,去网上下载一个itextpdf.jar。导出pdf的格式都是需要自己用代码实现的,每一行 ,每一个列是什么格式,都需要自己写出来,是不能够自动生成的,反正很麻烦。我做的一个导出成pdf特定格式的东西,写了好几千行代码。相当头痛。
package com.dw.mqs.export;
import java.awt.Color;
import java.io.ByteArrayOutputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dw.file.WebHelper;
import com.dw.mqs.MqsManager;
import com.dw.mqs.MqsUtilNew;
import com.dw.mqs.ProctItem;
import com.dw.mqs.ProjectBasicItem;
import com.dw.mqs.ProjectConfDetailItem;
import com.dw.mqs.ProjectConfVerItem;
import com.dw.mqs.ProjectConfig;
import com.dw.mqs.ProjectService;
import com.dw.mqs.Util;
import com.dw.system.Convert;
import com.dw.system.gdb.DBResult;
import com.dw.system.gdb.DataRow;
import com.dw.system.gdb.GDB;
import com.dw.user.User;
import com.dw.user.UserManager;
import com.dw.user.UserProfile;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class PdfService
{
Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);
ByteArrayOutputStream os = new ByteArrayOutputStream();
PdfWriter pdf = PdfWriter.getInstance(document, os);
Rectangle rect = new Rectangle(36, 54, 559, 788);
pdf.setBoxSize("art", rect);
pdf.setPageEvent(new TableHeader());
document.open();
BaseFont baseArialuni = BaseFont.createFont("res/ARIALUNI.TTF",
BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // Arial
// unicode字体
Font fontCN = new Font(baseArialuni, 9, Font.NORMAL, Color.BLACK);
Font fontCN8b = new Font(baseArialuni, 9, Font.BOLD, Color.BLACK);
Font fontCN12b = new Font(baseArialuni, 12, Font.BOLD, Color.BLACK);
Font fontCN9b = new Font(baseArialuni, 10, Font.BOLD, Color.BLACK);
Font fontCN9 = new Font(baseArialuni, 10, Font.NORMAL, Color.BLACK);
Font fontCN9b_blue = new Font(baseArialuni, 10, Font.BOLD, Color.BLUE);
PdfPTable table = null;
PdfPCell cell = null;
table = new PdfPTable(relativeWidths);
table.setWidthPercentage(100);
cell = new PdfPCell(new Paragraph(tit + "标题", fontCN12b));
cell.setColspan(root ? 12 : 10);
cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 水平居中
cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中
cell.setBorder(Rectangle.NO_BORDER);
table.addCell(cell);
}
‘伍’ java生成pdf几种常见方式
用Spire.PDF for Java来生成PDF文档的效果不错,支持格式化操作比较多,可以参考下 Java 中创建 PDF 文档
‘陆’ 使用 java 编程,获取网路上的pdf文件
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.widget.Toast;
public class MyService2 extends Service {
Thread thread = new Thread() {
@Override
public void run() {
try {
// 声明抛出所有例外
URL tirc = new URL("http://www..com/img/_sylogo1.gif");
// 构建一URL对象
InputStream is = tirc.openStream();
FileOutputStream fos = new FileOutputStream(
"/mnt/sdcard/_sylogo21.gif");
byte[] buffer = new byte[1024];
int len = is.read(buffer);
while (len != -1) {
fos.write(buffer, 0, len);
len = is.read(buffer);
}
fos.close();
is.close();
handler.sendEmptyMessage(1);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
Toast.makeText(MyService2.this, "下载完成...", Toast.LENGTH_LONG)
.show();
break;
}
}
};
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Toast.makeText(this, "Service onStart...", Toast.LENGTH_LONG).show();
thread.start();
}
@Override
public void onCreate() {
super.onCreate();
Toast.makeText(this, "Service created...", Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service destroyed...", Toast.LENGTH_LONG).show();
}
}
把链接地址改了就可以了
‘柒’ java 如何访问pdf文件
1、使用文件输入输出流方式读写;
2、itext.jar 构建Document结构读写
‘捌’ java语言怎么通过点击一个pdf文件超链接,实现pdf文件在线(html)预览。如下图:
到 http://get.adobe.com/cn/reader/ 下载
安装Adobe Reader 就可以了。如果你是制作网页,那超链接直接指向PDF文件就可以了。例如:
<a href="xxxx.pdf">在线浏览PDF文件</a>
‘玖’ 谁能搞个Java网络编程(第四版)pdf
《Java网络编程(第4版)》中文版.pdf 下载
更多java 书籍pdf 点击这里
‘拾’ java怎么实现下载指定网页中包含的pdf文件。 求代码
解析指定页面,得到pdf文件的地址,用URL来取回pdf的输入流,然后写到本地文件。