我有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的輸入流,然後寫到本地文件。