導航:首頁 > 文檔加密 > javaguipdf

javaguipdf

發布時間:2022-09-08 11:26:09

Ⅰ 《java核心技術卷II高級特性第9版》pdf下載在線閱讀全文,求百度網盤雲資源

《Java核心技術卷II高級特性第9版》網路網盤pdf最新全集下載:
鏈接:https://pan..com/s/1wO9zrRScVJ_RWHzOYlkySg

?pwd=6ger 提取碼:6ger
簡介:Java領域最有影響力和價值的著作之一,由擁有20多年教學與研究經驗的資深Java技術專家撰寫(獲Jolt大獎),與《Java編程思想》齊名,10餘年全球暢銷不衰,廣受好評。第9版根據Java SE7全面更新,同時修正了第8版中的不足,系統全面講解Java語言的核心概念、語法、重要特性和開發方法。本書全面覆蓋Java技術的高級主題,包括流與文件、XML、網路、資料庫編程、國際化等,詳細描述了圖形與GUI編程,還涉及安全、遠程方法、註解處理、本地方法等。本書對Java技術的闡述精確到位,敘述方式深入淺出,並包含大量示例代碼,能夠幫助讀者充分理解Java語言並靈活應用。

Ⅱ 怎麼用java代碼生成pdf文檔

package com.qhdstar.java.pdf;
import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.pdf.PdfWriter;

/**
* 描述:TODO 【JAVA生成PDF】
* <p>
*
* @title GeneratePDF
* @author SYJ
* @email [email protected]
* @date 2013-4-6
* @version V1.0
*/
public class GeneratePDF {

public static void main(String[] args) {

//調用第一個方法,向C盤生成一個名字為ITextTest.pdf 的文件
try {
writeSimplePdf();
}
catch (Exception e) { e.printStackTrace(); }

//調用第二個方法,向C盤名字為ITextTest.pdf的文件,添加章節。
try {
writeCharpter();
}
catch (Exception e) { e.printStackTrace(); }

}

public static void writeSimplePdf() throws Exception {

// 1.新建document對象
// 第一個參數是頁面大小。接下來的參數分別是左、右、上和下頁邊距。
Document document = new Document(PageSize.A4, 50, 50, 50, 50);

// 2.建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁碟中。
// 創建 PdfWriter 對象 第一個參數是對文檔對象的引用,第二個參數是文件的實際名稱,在該名稱中還會給出其輸出路徑。
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\ITextTest.pdf"));

// 3.打開文檔
document.open();

// 4.向文檔中添加內容
// 通過 com.lowagie.text.Paragraph 來添加文本。可以用文本及其默認的字體、顏色、大小等等設置來創建一個默認段落
document.add(new Paragraph("First page of the document."));
document.add(new
Paragraph("Some more text on the first page with different color and
font type.", FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new
Color(255, 150, 200))));

// 5.關閉文檔
document.close();
}

/**
* 添加含有章節的pdf文件
*
* @throws Exception
*/
public static void writeCharpter() throws Exception {

// 新建document對象 第一個參數是頁面大小。接下來的參數分別是左、右、上和下頁邊距。
Document document = new Document(PageSize.A4, 20, 20, 20, 20);

// 建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁碟中。
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\ITextTest.pdf"));

// 打開文件
document.open();

// 標題
document.addTitle("Hello mingri example");

// 作者
document.addAuthor("wolf");

// 主題
document.addSubject("This example explains how to add metadata.");
document.addKeywords("iText, Hello mingri");
document.addCreator("My program using iText");

// document.newPage();
// 向文檔中添加內容
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new
Paragraph("Some more text on the first page with different color and
font type.", FontFactory.getFont(FontFactory.defaultEncoding, 10,
Font.BOLD, new Color(0, 0, 0))));
Paragraph title1 = new
Paragraph("Chapter 1", FontFactory.getFont(FontFactory.HELVETICA, 18,
Font.BOLDITALIC, new Color(0, 0, 255)));

// 新建章節
Chapter chapter1 = new Chapter(title1, 1);
chapter1.setNumberDepth(0);
Paragraph
title11 = new Paragraph("This is Section 1 in Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255,
0, 0)));
Section section1 = chapter1.addSection(title11);
Paragraph someSectionText = new Paragraph("This text comes as part of section 1 of chapter 1.");
section1.add(someSectionText);
someSectionText = new Paragraph("Following is a 3 X 2 table.");
section1.add(someSectionText);
document.add(chapter1);

// 關閉文檔
document.close();
}

}

Ⅲ java中如何實現向已有的PDF文件插入附件

可以用Spire.Pdf for Java類庫給PDF文檔添加附件,下面的代碼是插入Excel和Word附件給你參考:

import com.spire.pdf.annotations.*;

import com.spire.pdf.attachments.PdfAttachment;

import com.spire.pdf.graphics.*;

import java.awt.*;

import java.awt.geom.Dimension2D;

import java.awt.geom.Rectangle2D;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

public class AttachFiles {
public static void main(String[] args) throws IOException {


//創建PdfDocument對象


PdfDocument doc = new PdfDocument();


//載入PDF文檔


doc.loadFromFile("C:\Users\Administrator\Desktop\sample.pdf");


//添加附件到PDF


PdfAttachment attachment = new PdfAttachment("C:\Users\Administrator\Desktop\使用說明書.docx");


doc.getAttachments().add(attachment);


//繪制標簽

String label = "財務報表.xlsx";


PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS",Font.PLAIN,12),true);


double x = 35;


double y = doc.getPages().get(0).getActualSize().getHeight() - 200;


doc.getPages().get(0).getCanvas().drawString(label, font, PdfBrushes.getOrange(), x, y);

//添加註釋附件到PDF


String filePath = "C:\Users\Administrator\Desktop\財務報表.xlsx";


byte[] data = toByteArray(filePath);


Dimension2D size = font.measureString(label);


Rectangle2D bound = new Rectangle2D.Float((float) (x + size.getWidth() + 2), (float) y, 10, 15);


PdfAttachmentAnnotation annotation = new PdfAttachmentAnnotation(bound, filePath, data);


annotation.setColor(new PdfRGBColor(new Color(0, 128, 128)));


annotation.setFlags(PdfAnnotationFlags.Default);


annotation.setIcon(PdfAttachmentIcon.Graph);


annotation.setText("點擊打開財務報表.xlsx");


doc.getPages().get(0).getAnnotationsWidget().add(annotation);

//保存文檔


doc.saveToFile("Attachments.pdf");
}

//讀取文件到byte數組


public static byte[] toByteArray(String filePath) throws IOException {

File file = new File(filePath);


long fileSize = file.length();


if (fileSize > Integer.MAX_VALUE) {


System.out.println("file too big...");


return null;


}


FileInputStream fi = new FileInputStream(file);


byte[] buffer = new byte[(int) fileSize];


int offset = 0;


int numRead = 0;


while (offset < buffer.length && (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) {


offset += numRead;


}

if (offset != buffer.length) {


throw new IOException("Could not completely read file "
+ file.getName());


}


fi.close();


return buffer;


}


}

效果:

Ⅳ 《JAVA數字圖像處理》pdf下載在線閱讀全文,求百度網盤雲資源

《JAVA數字圖像處理》網路網盤pdf最新全集下載:
鏈接: https://pan..com/s/1dBgm094OBx5BojEk_BmRFg

?pwd=f8sq 提取碼: f8sq
簡介:在開始本書內容之前,筆者假設你已經有了面向對象語言編程的基本概念,了解Java語言的基本語法與特徵,原因在於本書的所有源代碼都是基於Java語言實現的,而且是基於Java開發環境運行與演示所有圖像處理演算法的。本書第1章到第3章是為了幫助讀者了解與掌握Java圖形與GUI編程的基本知識與概念而寫的。本章主要介紹Java GUI編程中基本的圖形知識,針對GU1編程,Java語言提供了兩套幾乎並行的API,分別是Swing與AWT。早期的Java GUJ編程中主要使用AWT的相關組件,但是AWT的功能並不是十分強大,而且嚴重依賴本地介面。於是在Java 1.3及後續版本中引入了Swing工具實現GUl編程,Swing中的組件大多數都是基於純Java語言實現的,而不是通過本地組件實現的,所以它們是輕量級的GUI組件,同時Swing對圖形與圖像的支持操作也有很大的提高與增強。如何區分AWT組件與Swing組件?一個簡單而且相當直觀的方法是看Class的名稱,Swing的組件大多數帶有大寫的前綴字母J。

Ⅳ JAVA GUI

恩 用JTextArea就可以,至於你說的每次要保留上方的信息很簡單啊
只要定義一個StringBuffer類型的變數始終去累加JTextArea里的值就可以了

也就是每次在JTextArea顯示的東西都是上次的和這次新輸入的

Ⅵ 用JAVA編寫一個GUI記事本程序,實現文本的輸入,保存,修改,打開操作

代碼如下:

importjava.io.*;
importjava.awt.*;
importjava.awt.event.*;

publicclassjtxtfm{
publicstaticvoidmain(Stringargs[]){
jtxtfrmfm=newjtxtfrm();
}
}
{
FileDialogop,sv;
Buttonbtn1,btn2,btn3;
TextAreatarea;
jtxtfrm(){
super("讀寫文件");
setLayout(null);
setBackground(Color.cyan);
setSize(600,300);
setVisible(true);
btn1=newButton("打開");
btn2=newButton("保存");
btn3=newButton("關閉");
tarea=newTextArea("");
add(btn1);add(btn2);add(btn3);add(tarea);
tarea.setBounds(30,50,460,220);
btn1.setBounds(520,60,50,30);
btn2.setBounds(520,120,50,30);
btn3.setBounds(520,180,50,30);
op=newFileDialog(this,"打開",FileDialog.LOAD);
sv=newFileDialog(this,"保存",FileDialog.SAVE);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
addWindowListener(
newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
setVisible(false);
System.exit(0);
}
}
);
}

publicvoidactionPerformed(ActionEvente){
if(e.getSource()==btn1){
Stringstr;
op.setVisible(true);
try{
Filef1=newFile(op.getDirectory(),op.getFile());
FileReaderfr=newFileReader(f1);
BufferedReaderbr=newBufferedReader(fr);
tarea.setText("");
while((str=br.readLine())!=null)tarea.append(str+' ');
fr.close();
}
catch(Exceptione1)
{}
}

if(e.getSource()==btn2){
sv.setVisible(true);
try{
Filef1=newFile(sv.getDirectory(),sv.getFile());
FileWriterfw=newFileWriter(f1);
BufferedWriterbw=newBufferedWriter(fw);
Stringgt=tarea.getText();
bw.write(gt,0,gt.length());
bw.flush();
fw.close();
}
catch(Exceptione2)
{}
}

if(e.getSource()==btn3){
System.exit(0);
}

}
}

效果圖:

Ⅶ java gui 小程序實現

按照你的要求編寫的TreasureHunter程序如下:

(包括TreasureHunter.java和GameResult.java兩個文件,都加了注釋,沒寫用戶手冊,希望你自己補上)

如果沒有問題請採納我的回答。

Ⅷ java怎麼輸出pdf格式的文件

java導出pdf需要用到iText庫,iText是著名的開放源碼的站點sourceforge一個項目,是用於生成PDF文檔的一個java類庫。通過iText不僅可以生成PDF或rtf
的文檔,而且可以將XML、Html文件轉化為PDF文件。
iText的安裝非常方便,下載iText.jar文件後,只需要在系統的CLASSPATH中加入iText.jar的路徑,在程序中就可以使用
iText類庫了。
代碼如下:

public class createPdf {
//自己做的一個簡單例子,中間有圖片之類的
//先建立Document對象:相對應的 這個版本的jar引入的是com.lowagie.text.Document
Document document = new Document(PageSize.A4, 36.0F, 36.0F, 36.0F, 36.0F);
public void getPDFdemo() throws DocumentException, IOException{
//這個導出用的是 iTextAsian.jar 和iText-2.1.3.jar 屬於比較老的方法。 具體下在地址見:
//首先
//字體的定義:這里用的是自帶的jar裡面的字體
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);
// 當然你也可以用你電腦裡面帶的字體庫
//BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMSUN.TTC,1",BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
//定義字體 注意在最新的包裡面 顏色是封裝的
Font fontChinese8 = new Font(bfChinese, 10.0F, 0, new Color(59, 54, 54));
//生成pdf的第一個步驟:
//保存本地指定路徑
saveLocal();
document.open();
ByteArrayOutputStream ba = new ByteArrayOutputStream();
// PdfWriter writer = PdfWriter.getInstance(document, ba);
document.open();
//獲取此編譯的文件路徑
String path = this.getClass().getClassLoader().getResource("").getPath();
//獲取根路徑
String filePath = path.substring(1, path.length()-15);
//獲取圖片路徑 找到你需要往pdf上生成的圖片
//這里根據自己的獲取的路徑寫 只要找到圖片位置就可以
String picPath = filePath +"\\WebContent" +"\\images\\";
//往PDF中添加段落
Paragraph pHeader = new Paragraph();
pHeader.add(new Paragraph(" 你要生成文字寫這里", new Font(bfChinese, 8.0F, 1)));
//pHeader.add(new Paragraph("文字", 字體 可以自己寫 也可以用fontChinese8 之前定義好的 );
document.add(pHeader);//在文檔中加入你寫的內容
//獲取圖片
Image img2 = Image.getInstance(picPath +"ccf-stamp-new.png");
//定義圖片在文檔中顯示的絕對位置
img2.scaleAbsolute(137.0F, 140.0F);
img2.setAbsolutePosition(330.0F, 37.0F);
//將圖片添加到文檔中
document.add(img2);
//關閉文檔
document.close();
/*//設置文檔保存的文件名
response.setHeader("Content-
disposition", "attachment;filename=\""+ new String(("CCF會員資格確認
函.pdf").getBytes("GBK"),"ISO-8859-1") + "\"");
//設置類型
response.setContentType("application/pdf");
response.setContentLength(ba.size());
ServletOutputStream out = response.getOutputStream();
ba.writeTo(out);
out.flush();*/
}
public static void main(String[]args) throws DocumentException, IOException{
createPdf pdf= new createPdf();
pdf.getPDFdemo();
}

//指定一個文件進行保存 這里吧文件保存到D盤的text.pdf
public void saveLocal() throws IOException, DocumentException{
//直接生成PDF 制定生成到D盤test.pdf
File file = new File("D:\\text2.pdf");
file.createNewFile();
PdfWriter.getInstance(document, new FileOutputStream(file));

}
}

Ⅸ 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);

}

閱讀全文

與javaguipdf相關的資料

熱點內容
java如何從雲伺服器讀取本地文件 瀏覽:915
壓縮空氣軟管製作方法 瀏覽:907
天河三號演算法 瀏覽:924
php隊列教程 瀏覽:632
洪水命令 瀏覽:529
安卓怎麼弄成蘋果在線 瀏覽:435
谷歌web伺服器地址 瀏覽:898
安卓鎖屏圖片如何刪除 瀏覽:719
python3多進程編程 瀏覽:714
證明代碼是程序員寫的 瀏覽:397
演算法錯誤發現辦法 瀏覽:410
河南省醫院掛號是哪個app 瀏覽:629
冬日戀歌哪個APP能看 瀏覽:673
委內瑞拉加密貨 瀏覽:10
程序員寫日記哪個軟體好 瀏覽:108
加密機操作手冊 瀏覽:860
dos命令自動關閉 瀏覽:328
心田花開app在哪裡評價 瀏覽:449
求索記錄頻道哪個app可以看 瀏覽:730
金梅瓶pdf下載 瀏覽:985