导航:首页 > 文档加密 > 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相关的资料

热点内容
如何改变appstore的语言 浏览:458
javahtmlxml 浏览:26
单片机启动文件 浏览:805
橙app如何开启聊天 浏览:899
访问服务器公网地址 浏览:666
pdf打印底色去掉 浏览:463
java快递接口 浏览:397
哪个app可以教新爸爸 浏览:210
如何查看服务器系统版本信息 浏览:524
成都市土地出让金算法 浏览:702
钢筋加密标记 浏览:576
ps中扩展功能在文件夹的什么位置 浏览:904
双极压缩机为什么要先高压 浏览:527
苹果手机服务器填什么 浏览:832
android移动动画效果 浏览:691
电子和服务器是什么意思 浏览:692
phpurl中文乱码问题 浏览:893
程序员那么可爱大结局陆漓产子 浏览:538
java如何从云服务器读取本地文件 浏览:924
压缩空气软管制作方法 浏览:913