-
2021-10-28 11:53:12
maven依赖
<dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> </dependency> <!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency>。
pdf工具
public class PdfUtil {
// 定义全局的字体静态变量
private static Font titlefont;
private static Font headfont;
private static Font keyfont;
private static Font textfont;
private static Font textfont1;
// 最大宽度
private static int maxWidth = 520;
// 静态代码块
static {
try {
// 不同字体(这里定义为同一种字体:包含不同字号、不同style)
BaseFont bfChinese = BaseFont.createFont(“STSong-Light”, “UniGB-UCS2-H”, BaseFont.NOT_EMBEDDED);
titlefont = new Font(bfChinese, 15, Font.NORMAL);
textfont1 = new Font(bfChinese, 12, Font.NORMAL);
headfont = new Font(bfChinese, 10, Font.NORMAL);
keyfont = new Font(bfChinese, 10, Font.NORMAL);
textfont = new Font(bfChinese, 10, Font.NORMAL);} catch (Exception e) { e.printStackTrace(); } } // 生成PDF文件 public static void generatePDF(List<Student> list, String title) throws Exception { int code = 0; Map<String,String> printMap = new HashMap<>(); System.out.println("此次打印数量:"+list.size()); for (Student student : list) { code++; System.out.println("当前孩子:"+student.getStudentName()+"正在生成pdf,打印序号:"+code); // 1.新建document对象 Document document = new Document(PageSize.A4);// 建立一个Document对象 // 2.建立一个书写器(Writer)与document对象关联 String printUrl = "/Users/sim/Desktop/"+student.getSchoolName()+student.getGradeName()+student.getClassName()+"-"+student.getStudentName()+".pdf"; File file = new File(printUrl); file.createNewFile(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // 3.打开文档 document.open(); document.addTitle("sim");// 标题 document.addAuthor("sim@umiz");// 作者 document.addSubject("Ssim");// 主题 document.addKeywords("sim");// 关键字 document.addCreator("sim");// 创建者 // 段落 Paragraph paragraph = new Paragraph(title, titlefont); paragraph.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右 paragraph.setIndentationLeft(12); //设置左缩进 paragraph.setIndentationRight(12); //设置右缩进 paragraph.setFirstLineIndent(24); //设置首行缩进 paragraph.setLeading(20f); //行间距 paragraph.setSpacingBefore(50f); //设置段落上空白 paragraph.setSpacingAfter(30f); //设置段落下空白 // 表格 PdfPTable table = createTable(new float[] { 100, 80, 80, 70, 70}); table.addCell(newCreateCell("姓名:"+student.getStudentName(), 30f)); table.addCell(newCreateCell("性别:"+student.getSexName(), 30f)); table.addCell(newCreateCell("年龄:"+student.getAge(), 30f)); table.addCell(newCreateCell("身高:"+student.getHeight()+"(m)",30f)); table.addCell(newCreateCell("体重:"+student.getWeight()+("kg"), 30f)); PdfPTable table1 = createTable(new float[] { 100, 80, 80, 70, 70}); table1.addCell(newCreateCell("学校:"+student.getSchoolName(),30f)); table1.addCell(newCreateCell("年级:"+student.getGradeName(),30f)); table1.addCell(newCreateCell("班级:"+student.getClassName(),30f)); table1.addCell(newCreateCell("BMI:"+student.getBmi(),30f)); table1.addCell(newCreateCell("",20f)); PdfPTable table2 = createTable(new float[] { 100, 300}); table2.addCell(newCreateCell("体检结果",50f)); String weightName = ""; String heightName = ""; if(!student.getWeightName().equals("正常")){ weightName = "体重:"+student.getWeightName()+"(建议到儿童内分泌科或生长发育科复查)\n\n"; }else { weightName = "体重:正常 (建议定期观察生长速率)\n\n"; } if(!student.getHeightName().equals("正常")){ heightName = "身高:"+student.getHeightName()+"(建议到儿童内分泌科或生长发育科复查)\n\n"; }else { heightName = "身高:正常 (建议定期观察生长速率)"; } table2.addCell(newCreateCell(weightName+heightName,50f)); PdfPTable table3 = createTable(new float[] { 100, 300}); table3.addCell(newCreateCell("温馨提示",180f)); table3.addCell(newCreateCell("孩子的成长只有一次!我们建议:\n" + "\n" + "1、每天1-2小时户外运动。\n" + " 在以下项目中选择一项或两项(跳绳、游泳、有氧跑、有氧韵律操、羽毛球、网球、篮球、排球等纵向体育运动)。\n" + "\n" + "2、合理饮食,吃饱吃好一日三餐,荤素搭配,可适当多吃点鱼类少吃肉类,每天确保一个鸡蛋、250-500ml牛奶及水果等。\n" + "\n" + "3、充足规律的睡眠,晚上熟睡后体内生长激素分泌旺盛,并有两个分泌高峰期,因此充足规律的睡眠有利于孩子更好的长高。\n" + "\n" + "4、给孩子创造一个快乐、心情舒畅的生活环境,让孩子保持乐观向上的心态,不要过于宠溺孩子,适当的规矩是对孩子最好的保护。",180f)); Paragraph paragraph1 = new Paragraph("关爱儿童,呵护成长", textfont1); paragraph1.setAlignment(1); //设置文字居中 0靠左 1,居中 2,靠右 paragraph1.setIndentationLeft(12); //设置左缩进 paragraph1.setIndentationRight(12); //设置右缩进 paragraph1.setFirstLineIndent(24); //设置首行缩进 paragraph1.setLeading(20f); //行间距 paragraph1.setSpacingBefore(50f); //设置段落上空白 paragraph1.setSpacingAfter(10f); //设置段落下空白 document.add(paragraph); document.add(table); document.add(table1); document.add(table2); document.add(table3); document.add(paragraph1); document.close(); printMap.put(student.getStudentName(),printUrl); } System.out.println("pdf生成完成,准备开始打印"); for(String key:printMap.keySet()){ System.out.println("开始打印"+key+"的报告"); String printUrl = printMap.get(key).toString(); PrintUtil.defaultPrintPDF(printUrl); System.out.println("等待5s"); Thread.sleep(5000); } } /** * 创建单元格(指定字体) * @param value * @param font * @return */ public PdfPCell createCell(String value, Font font) { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPhrase(new Phrase(value, font)); return cell; } public static PdfPCell newCreateCell(String value,float height){ PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase(new Phrase(value, keyfont)); cell.setFixedHeight(height); return cell; } /** * 创建单元格(指定字体、水平..) * @param value * @param font * @param align * @return */ public PdfPCell createCell(String value, Font font, int align) { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(align); cell.setPhrase(new Phrase(value, font)); return cell; } /** * 创建单元格(指定字体、水平居..、单元格跨x列合并) * @param value * @param font * @param align * @param colspan * @return */ public PdfPCell createCell(String value, Font font, int align, int colspan) { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(align); cell.setColspan(colspan); cell.setPhrase(new Phrase(value, font)); return cell; } /** * 创建单元格(指定字体、水平居..、单元格跨x列合并、设置单元格内边距) * @param value * @param font * @param align * @param colspan * @param boderFlag * @return */ public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(align); cell.setColspan(colspan); cell.setPhrase(new Phrase(value, font)); cell.setPadding(3.0f); if (!boderFlag) { cell.setBorder(0); cell.setPaddingTop(15.0f); cell.setPaddingBottom(8.0f); } else if (boderFlag) { cell.setBorder(0); cell.setPaddingTop(0.0f); cell.setPaddingBottom(15.0f); } return cell; } /** * 创建单元格(指定字体、水平..、边框宽度:0表示无边框、内边距) * @param value * @param font * @param align * @param borderWidth * @param paddingSize * @param flag * @return */ public PdfPCell createCell(String value, Font font, int align, float[] borderWidth, float[] paddingSize, boolean flag) { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(align); cell.setPhrase(new Phrase(value, font)); cell.setBorderWidthLeft(borderWidth[0]); cell.setBorderWidthRight(borderWidth[1]); cell.setBorderWidthTop(borderWidth[2]); cell.setBorderWidthBottom(borderWidth[3]); cell.setPaddingTop(paddingSize[0]); cell.setPaddingBottom(paddingSize[1]); if (flag) { cell.setColspan(2); } return cell; } /** * 创建默认列宽,指定列数、水平(居中、右、左)的表格 * @param colNumber * @param align * @return */ public PdfPTable createTable(int colNumber, int align) { PdfPTable table = new PdfPTable(colNumber); try { table.setTotalWidth(maxWidth); table.setLockedWidth(true); table.setHorizontalAlignment(align); table.getDefaultCell().setBorder(1); } catch (Exception e) { e.printStackTrace(); } return table; } /** * 创建指定列宽、列数的表格 * @param widths * @return */ public static PdfPTable createTable(float[] widths) { PdfPTable table = new PdfPTable(widths); try { table.setTotalWidth(maxWidth); table.setLockedWidth(true); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setBorder(1); } catch (Exception e) { e.printStackTrace(); } return table; } /** * 创建空白的表格 * @return */ public PdfPTable createBlankTable() { PdfPTable table = new PdfPTable(1); table.getDefaultCell().setBorder(0); table.addCell(createCell("", keyfont)); table.setSpacingAfter(20.0f); table.setSpacingBefore(20.0f); return table; }
打印工具
public class PrintUtil {
/**
* 通过本机默认打印机打印pdf文件
* @param filePath 文件路径
* @throws Exception
*/
public static void defaultPrintPDF(String filePath) throws Exception{
File file = new File(filePath); // 获取选择的文件
// 构建打印请求属性集
HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
// 设置打印格式,因为未确定类型,所以选择autosense
DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
//pras.add(MediaName.ISO_A4_TRANSPARENT);//A4纸张
//遍历
// PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
//
// for (PrintService printService2 : printService) {
// logger.info(“本机可使用打印机列表:===================”+printService2);
// }
// 定位默认的打印服务
PrintService defaultService = PrintServiceLookup
.lookupDefaultPrintService();
DocPrintJob job = defaultService.createPrintJob(); // 创建打印作业
FileInputStream fis = new FileInputStream(file); // 构造待打印的文件流
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
}更多相关内容 -
奈末PDF批量打印助手 v9.7.4绿色版
2020-12-23 21:41:01为您提供奈末PDF批量打印助手下载,奈末PDF批量打印助手支持本地打印机和共享打印机,奈末PDF批量打印助手可以将多个PDF、XPS文档批量打印,无需打开文件即可打印,同时可以设置每个文档打印份数。使用方法 1.点击... -
易语言PDF批量打印PDF文件-易语言
2021-06-12 08:11:29本软件是调用HWPostil.ocx实现PDF批量打印的 找了好久才找到这个插件 -
07 Office,PDF批量打印软件.zip
2019-09-01 21:30:23已破解且可用的批量打印软件,欢迎大家下载体验,软件绿色免安装。 -
PDF批量打印
2014-09-17 10:48:59进行PDF的文件的批量打印,这样打印多文件,不再烦恼了! -
易语言-易语言PDF批量打印PDF文件
2021-06-25 19:05:17PDF文件批量打印源码+插件,本软件是调用HWPostil.ocx实现PDF批量打印的。 -
dwg批量打印pdfdwg批量打印pdf
2021-12-06 11:23:57本脚本是通过VBA实现dwg批量输出pdf,需要用到模板配对打印,dwg模板和doc模板,打印出来线太细时,需要把线加固定宽度,出现打印后看不到的问题时,可能 _ 是图层颜色问题,输出pdf报错问题可能是需要安装插件 -
java 打印pdf文件 也可批量打印
2015-10-29 15:20:52java 打印pdf文件 ,也可支持批量打印 -
PDF批量打印的软件
2021-01-03 15:10:24CAD批量打印 -
java使用itextpdf生成PDF批量打印荣誉证书(指定位置输出文字)
2018-07-03 09:17:45最近公司项目有个需求,批量打印荣誉证书,一开始尝试过传统的Web打印,控件打印,js调用浏览器打印方法,遇到各种问题,比如定位不准,分页问题,缩放问题等。然后就自己研究,整理了一套打印方案,项目已测试通过...最近公司项目有个需求,批量打印荣誉证书,一开始尝试过传统的网络打印,控件打印,JS调用浏览器打印方法,遇到各种问题,比如定位不准,分页问题,缩放问题等。然后就自己研究,整理了一套打印方案,项目已测试通过,现在把这一成果分享给大家。
下面,我会提供一个工具类,这个工具类里,会有两种打印方案:
一。把要打印的内容,放到HTML代码中,然后解析HTML(虽然支持解析样式,由于支持的样式非常少,字体字号样式都不支持,所以这种方式并没有太大意义),解析后生成PDF文件,然后下载到客户端。
二,先生成多页的空白PDF,然后将文字通过添加水印(可设置透明度)的方式,输出指定位置。
注意事项:在这个过程中,会产生一些临时文件,注意临时文件存放目录,由于项目运行时必然有并发问题,临时文件名一定要取时间戳或UUID这种不会重复的名字,还有临时文件使用完成后要及时删除,删除前要关闭IO流对象,PDF格式书写器对象(关闭要由外到里,一定要关闭掉,因为JVM的GC无法回收这些资源,否则是不能删除这些被占用的临时文件的)
代码里使用的字体文件xxx.TTF,到windows电脑字体库里拿“C:\ Windows \ Fonts”
相关jar下载链接:https://download.csdn.net/download/qq_29062045/10519043
包com.chinauip.contract.service.contract;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontProvider;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfGState;
import com.itextpdf.text.pdf.PdfImportedPage;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;
/ **
*
* @author YuGongWen 2018年6月27日上午八点20分31秒packagepath的:
* com.chinauip.contract.service.contract.pdfPrintUtil.java
*
* /
公共类pdfPrintUtil { / ** *生成打印PDF文件(多个企业)* * @参数printParam * @返回* @throws 异常* / 公共静态字符串creatPdf(列表<地图<字符串,对象>> printParam,字符串modeltype,字符串路径)抛出异常{ 列表<字符串>文件=新ArrayList <字符串>(); for(int i = 0; 我<printParam.size(); i ++){ String filePath = new pdfPrintUtil()。createSinglePdf(path,printParam.get(i),modeltype); files.add(文件路径); }
String savepath = path + String.valueOf(new Date()。getTime())+“。pdf”; savepath = mergePdfFiles(files,savepath); for(int i = 0; 我<files.size(); i ++){ forceDelete(files.get(i)); } 的System.out.println(“合成PDF的路径:”+ savepath); return savepath; } / ** *生成的HTML模板代码(模板1)* * @参数parMap * @返回* @throws UnsupportedEncodingException * / 公共静态字符串getHtml1(地图<字符串,对象> parMap)抛出UnsupportedEncodingException { 字符串certificate_number = parMap.get( “certificate_number”)!= null?parMap.get(“certificate_number”)。toString():“”; String year = parMap.get(“year”)!
= null?parMap.get(“year”)。toString():“”; String enterprise_name = parMap.get(“enterprise_name”)!= null?parMap.get(“enterprise_name”)。toString():“”; String month = parMap.get(“month”)!= null?parMap.get(“month”)。toString():“”; String day = parMap.get(“day”)!= null?parMap.get(“day”)。toString():“”; String first_time = parMap.get(“first_time”)!= null?parMap.get(“first_time”)。toString():“”; StringBuffer html = new StringBuffer(); html.append(“<div id ='model1'align ='center'>”); html.append(“<div style ='margin-left:60px'align ='center'>”); html.append(“<table border ='1'style ='width:100%; 高度:
html.append(“<td style ='width:40%'>”); html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”+ year); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<tr style ='height:100px;'>”); html.append(“<td style ='font-family:楷体';>”); html.append(“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&quot;”); html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;”); html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; ;“); html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;” + certificate_number +“ <br />“); html.append(“&
html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<tr style ='height:100px;'>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<tr style ='height:100px;'>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<tr style ='height:100px;'>”); html.append(“<TD>”); html.append(&& NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
html.append(“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&quot;”); html.append(“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;”); html.append(年+“&nbsp;&nbsp;&nbsp;”+月+“&nbsp;&nbsp;&nbsp;”+ day); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“<tr style ='height:100px;'>”); html.append(“<TD>”); html.append(“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;”); html.append(“&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
html.append(“</ DIV>”); return html.toString(); } / ** *生成的HTML模板代码(模板2)* * @参数parMap * @返回* @throws UnsupportedEncodingException * / 公共静态字符串getHtml2(地图<字符串,对象> parMap)抛出UnsupportedEncodingException { 字符串年= parMap.get( “年”)!= null?parMap.get(“year”)。toString():“”; String enterprise_name = parMap.get(“enterprise_name”)!= null?parMap.get(“enterprise_name”)。toString():“”; String month = parMap.get(“month”)!= null?parMap.get(“month”)。toString():“”; String day = parMap.get(“day”)!= null?parMap.get(“天”)。
String first_time = parMap.get(“first_time”)!= null?parMap.get(“first_time”)。toString():“”; StringBuffer html = new StringBuffer(); html.append(“<div id ='model2'align ='center'>”); html.append(“<div align ='center'>”); html.append(“<table border ='0'style ='width:80%; 高度:80%“>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<td width ='70%'>”); html.append(“</ TD>”); html.append(“<TD>”); HTML。
html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“<
return html.toString(); } / ** *生成的HTML模板代码(模板3)* * @参数parMap * @返回* @throws UnsupportedEncodingException * / 公共静态字符串getHtml3(地图<字符串,对象> parMap)抛出UnsupportedEncodingException { 字符串年= parMap.get( “年”)!= null?parMap.get(“year”)。toString():“”; String enterprise_name = parMap.get(“enterprise_name”)!= null?parMap.get(“enterprise_name”)。toString():“”; String month = parMap.get(“month”)!= null?parMap.get(“month”)。toString():“”; String day = parMap.get(“day”)!= null?parMap.get(“day”)。toString():“”;
String first_time = parMap.get(“first_time”)!= null?parMap.get(“first_time”)。toString():“”; StringBuffer html = new StringBuffer(); html.append(“<div id ='model3'align ='center'>”); html.append(“<table border ='0'style ='width:80%; 高度:80%“>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<
html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); HTML。附加(“</ TR>”); html.append(“</ TABLE>”); html.append(“</ DIV>”); return html.toString(); } / ** *生成html模板代码(模板4)
* * @param parMap * @return * @throws UnsupportedEncodingException * / public static String getHtml4(Map <String,Object> parMap)抛出UnsupportedEncodingException { String year = parMap.get(“year”)!= null?parMap.get( “年”)的toString():“”。String enterprise_name = parMap.get(“enterprise_name”)!= null?parMap.get(“enterprise_name”)。toString():“”; String month = parMap.get(“month”)!= null?parMap.get(“month”)。toString():“”; String day = parMap.get(“day”)!= null?parMap.get(“day”)。toString():“”; String first_time = parMap.get(“first_time”)!= null?parMap.get(“first_time”)。toString():“”; StringBuffer html = new StringBuffer();
html.append(“<div id ='model4'align ='center'>”); html.append(“<table border ='0'style ='width:80%; 高度:80%“>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<
html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”+ year); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“</ TABLE>”); html.append(“</ DIV>”); return html.toString();
UnsupportedEncodingException * / 公共静态字符串getHtml5(地图<字符串,对象> parMap)抛出UnsupportedEncodingException { !?字符串年= parMap.get(“年”)= NULL 。parMap.get(“年”)的toString():“” ; String enterprise_name = parMap.get(“enterprise_name”)!= null?parMap.get(“enterprise_name”)。toString():“”; String month = parMap.get(“month”)!= null?parMap.get(“month”)。toString():“”; String day = parMap.get(“day”)!= null?parMap.get(“day”)。toString():“”; String first_time = parMap.get(“first_time”)!= null?parMap.get(“first_time”)。toString():“”; StringBuffer html = new StringBuffer(); html.append(“<div id ='model5'
html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“<TR>”);
html.append(“<td width ='70%'>”); html.append(“</ TD>”); html.append(“<TD>”); html.append(“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;”+ year); html.append(“</ TD>”); html.append(“</ TR>”); html.append(“<TR>”); html.append(“<TD>”); html.append(“</ TD>”); html.append(“<TD> </ TD>”); html.append(“</ TR>”); html.append(“</ TABLE>”); html.append(“</ DIV>”); return html.toString();
BASEFONT bfChinese = NULL; 尝试{ bfChinese = BaseFont.createFont(“STSong-Light”,“UniGB-UCS2-H”,BaseFont.NOT_EMBEDDED); catch(例外e){ e.printStackTrace(); } Font FontChinese = new Font(bfChinese,12,Font.NORMAL); 返回FontChinese; } @覆盖公共布尔isRegistered(字符串为arg0){ 返回false; } } / ** *合并PDF文件* * @参数文件* @参数savepath * @throws异常* / 公共静态字符串mergePdfFiles(列表<字符串>文件,字符串savepath)抛出异常{ 文献文档= NULL; FileOutputStream outfile = null; PdfReader reader = null;尝试{
document = new Document(new PdfReader(files.get(0))。getPageSize(1)); outfile = new FileOutputStream(savepath); PdfCopy copy = new PdfCopy(document,outfile); document.open(); for(int i = 0; 我<files.size(); i ++){ reader = new PdfReader(files.get(i)); int n = reader.getNumberOfPages(); for(int j = 1; j <= n; j ++){ document.newPage(); PdfImportedPage page = copy.getImportedPage(reader,j); copy.addPage(页); } reader.close(); } } catch(Exception e){ e.printStackTrace(); 抛出新的例外(“merge -----生成pdf异常”,e); } finally { document.close(); try { outfile.close();
} catch(IOException e){ e.printStackTrace(); } reader.close(); } return savepath; } / ** *获取当前字符串的字符编码* * @param str * @return * / public static String getEncoding(String str){ String encode =“GB2312”; try { if(str.equals(new String(str.getBytes(encode),encode))){ String s = encode; 回归; }上上(例外的例外){ } 编码=“ISO-8859-1”; try { if(str.equals(new String(str.getBytes(encode),encode))){ String s1 = encode; 返回s1; }上上(例外exception1){ }
encode =“UTF-8”; try { if(str.equals(new String(str.getBytes(encode),encode))){ String s2 = encode; 返回s2; }上上(例外exception2){ } 编码=“GBK”; try { if(str.equals(new String(str.getBytes(encode),encode))){ String s3 = encode; 返回s3; } } catch(Exception exception3){ } return“”; } / ** *删除文件* * @param pathname * @return * @throws IOException * / public static boolean deleteFile(String pathname){ boolean result = false; 文件文件=新文件(路径名); 如果(file.exists()){
result = file.delete(); if(result){ System.out.println(“文件已经被删除成功!!”); } else { System.out.println(“文件已经被删除失败!!”); } } 返回结果; } / ** *强制删除文件* * @param文件* @return * / public static boolean forceDelete(String filePath){ File file = new File(filePath); boolean result = file.delete(); int tryCount = 0; while(!result && tryCount ++ <2){ System.gc(); //回收资源result = file.delete(); // System.out.println(“删除”+ tryCount +“次!”); } 返回结果;
* * @param文件* @return * / public static byte [] File2byte(文件文件){ byte [] buffer = null; 尝试{ FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte [] b = new byte [1024]; int n; while((n = fis.read(b))!= -1){ bos.write(b,0,n); } fis.close(); bos.close(); buffer = bos.toByteArray(); } catch(FileNotFoundException e){ e.printStackTrace(); } catch(IOException e){ e.printStackTrace(); } 返回缓冲区; } / ** *生成多页pdf * @throws Exception * /
public static String createPrintPdfFile(String path,List <Map <String,String >> paramMapList,String modeltype)throws Exception { //生成空白pdf 文档document = new Document(PageSize.A4.rotate(),0,0,0, 0); String filepath = path + UUID.randomUUID()+“。pdf”; FileOutputStream fileoutput = new FileOutputStream(filepath); PdfWriter.getInstance(文件,fileoutput); document.open(); for(int i = 0; 我<paramMapList.size(); i ++){ document.newPage(); //不能为空,否则无法添加页面document.add(新段落(“”)); } document.close(); fileoutput.close(); // 在pdf中添加文字String outputPath = path + UUID.randomUUID()+“。pdf”; 如果(“1”。
addWatermark(路径,文件路径,outputPath,paramMapList); } else { addWatermark2_5(path,filepath,outputPath,paramMapList,modeltype); } deleteFile(filepath); return outputPath; } / ** *在PDF上添加文字* @参数路径* @参数inputPath * @参数outputPath * @参数paramMapList * @throws 异常* / 私有静态无效addWatermark(字符串路径,字符串inputPath,字符串outputPath,列表<地图< String,String >> paramMapList)抛出异常{ PdfReader pdfReader = new PdfReader(inputPath); FileOutputStream fileoutputStream = new FileOutputStream(outputPath);
PdfStamper pdfStamper = new PdfStamper(pdfReader,fileoutputStream);
PdfContentByte content_company_name = null; PdfContentByte content_certificate_number = null; PdfContentByte content_month = null; PdfContentByte content_day = null; PdfContentByte content_continue_year = null; PdfContentByte content_year = null; PdfContentByte content_certificate_number_wenzi = null; PdfContentByte content_yeardu = null; PdfContentByte content_first_time = null; BaseFont basefont_kaiti = null; BaseFont basefont_songti = null; PdfGState pdfGstate = new PdfGState(); basefont_kaiti = BaseFont.createFont(path +“font / kaiti.TTF”,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
basefont_songti = BaseFont.createFont(path +“font / songti.TTF”,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED); // BaseFont bfChinese = BaseFont.createFont(“STSong-Light”,“UniGB-UCS2-H”,BaseFont.NOT_EMBEDDED); 尝试{ if(basefont_songti == null || basefont_kaiti == null){ throw new Exception(“生成打印pdf时,字体加载异常!!”); } //设置透明度为1.0不透明pdfGstate.setFillOpacity(1.0f); int toPage = pdfStamper.getReader()。getNumberOfPages(); for(int i = 1; 我<= toPage; i ++){ Map <String,String> paremMap = paramMapList.get(i-1); //遍历,检查参数是否有空或null,有则抛出异常Iterator <Map.Entry <String,String >> entries = paremMap.entrySet()。iterator(); int count = 0;
count ++; Map.Entry <String,String> entry = entries.next(); // System.out.println(“Key =”+ entry.getKey()+“,Value =”+ entry.getValue()); if(StringUtils.isBlank(entry.getValue())){ throw new Exception(“生成打印pdf时,解析传入参数时,发生异常,原因:参数”+ entry.getKey()+“为空值或者null ,请检查!!“); } } 如果(计数<8){ 抛出新的异常(“生成打印PDF格式时,解析传入参数时,发生异常,原因:缺少参数,请检查!!”); / enterprise解析传入的参数String enterprise_name = paremMap.get(“enterprise_name”); String certificate_number = paremMap.get(“certificate_number”); String year = paremMap.get(“year”); String month = paremMap.get(“month”);
String first_time = paremMap.get(“first_time”); String year_nd = paremMap.get(“year_nd”); String continue_year = paremMap.get(“continue_year”); //设置整体调整参数int yyy = 10 + 10 + 8; int xxx = -30 + 11 + 6; / * 参数说明:以纸张的左下角为坐标原点,纸张左边框为正Y轴,纸张底部为正X轴,把输出文字看作一个方块(具有左 - 右 - 上 - 下边框)xxx参数代表文字的左边框到Y轴的像素yyy参数代表文字的下边框到X轴的像素 * / //企业名称content_company_name = pdfStamper.getOverContent(i); content_company_name.saveState(); content_company_name.setGState(pdfGstate); content_company_name.beginText(); content_company_name.setColorFill(BaseColor.BLACK); content_company_name.setFontAndSize(basefont_kaiti,23); //
content_company_name.setFontAndSize(FontKaitiJiaCu,20);
// size()横坐标位置// 20 x-270 // 23 x-280 content_company_name.showTextAligned(Element.ALIGN_CENTER,enterprise_name,295 + xxx,375 + yyy,0); content_company_name.endText(); //证书编号前的文字content_certificate_number_wenzi = pdfStamper.getOverContent(i); content_certificate_number_wenzi.saveState(); content_certificate_number_wenzi.setGState(pdfGstate); content_certificate_number_wenzi.beginText(); content_certificate_number_wenzi.setColorFill(BaseColor.BLACK); content_certificate_number_wenzi.setFontAndSize(basefont_kaiti,14);
content_certificate_number_wenzi.showTextAligned(Element.ALIGN_CENTER,“证书编号:”,300 + xxx,420 + yyy,0); content_certificate_number_wenzi.endText(); //证书编号content_certificate_number = pdfStamper.getOverContent(i); content_certificate_number.saveState(); content_certificate_number.setGState(pdfGstate); content_certificate_number.beginText(); content_certificate_number.setColorFill(BaseColor.BLACK); content_certificate_number.setFontAndSize(basefont_kaiti,14); content_certificate_number.showTextAligned(Element.ALIGN_CENTER,certificate_number,380 + xxx,418 + yyy,0); content_certificate_number.endText(); //整体上移年月日int date_y = 4; //日期 - 年
content_year = pdfStamper.getOverContent(i); content_year.saveState(); content_year.setGState(pdfGstate); content_year.beginText(); content_year.setColorFill(BaseColor.BLACK); content_year.setFontAndSize(basefont_kaiti,14); content_year.showTextAligned(Element.ALIGN_CENTER,year,215 + xxx,112 + yyy + date_y,0); content_year.endText(); //日期 - 月content_month = pdfStamper.getOverContent(i); content_month.saveState(); content_month.setGState(pdfGstate); content_month.beginText(); content_month.setColorFill(BaseColor.BLACK); content_month.setFontAndSize(basefont_kaiti,14);
content_month.showTextAligned(Element.ALIGN_CENTER,month,280 + xxx,112 + yyy + date_y,0); content_month.endText(); //日期 - 天content_day = pdfStamper.getOverContent(i); content_day.saveState(); content_day.setGState(pdfGstate); content_day.beginText(); content_day.setColorFill(BaseColor.BLACK); content_day.setFontAndSize(basefont_kaiti,14); content_day.showTextAligned(Element.ALIGN_CENTER,day,335 + xxx,112 + yyy + date_y,0); content_day.endText(); //首次公示年度content_first_time = pdfStamper.getOverContent(i); content_first_time.saveState(); content_first_time.setGState(pdfGstate); content_first_time.beginText();
content_first_time.setColorFill(BaseColor.BLACK); content_first_time.setFontAndSize(basefont_kaiti,16); content_first_time.showTextAligned(Element.ALIGN_CENTER,first_time,220 + 6 + xxx,72-8 + yyy,0); content_first_time.endText(); //公示年度content_yeardu = pdfStamper.getOverContent(i); content_yeardu.saveState(); content_yeardu.setGState(pdfGstate); content_yeardu.beginText(); content_yeardu.setColorFill(BaseColor.BLACK); content_yeardu.setFontAndSize(basefont_kaiti,16); content_yeardu.showTextAligned(Element.ALIGN_CENTER,year_nd,510 + xxx,418-8 + yyy,0); content_yeardu.endText(); //连续年数content_continue_year = pdfStamper.getOverContent(i);
content_continue_year.saveState(); content_continue_year.setGState(pdfGstate); content_continue_year.beginText(); content_continue_year.setColorFill(BaseColor.BLACK); content_continue_year.setFontAndSize(basefont_kaiti,18); content_continue_year.showTextAligned(Element.ALIGN_CENTER,“连续”+ continue_year +“年”,650 + xxx,418-8 + yyy,0); content_continue_year.endText(); } }上的(例外){ ex.printStackTrace(); 抛出新的例外(“生成打印pdf时,添加文字异常,请检查!!”,ex); } finally { content_company_name = null; content_certificate_number = null; content_day = null; content_year = null; content_first_time = null; content_certificate_number_wenzi = null;
content_continue_year = null; content_yeardu = null; basefont_kaiti = null; pdfStamper.close(); pdfReader.close(); fileoutputStream.close(); } } / ** *在PDF上添加文字* @参数路径* @参数inputPath * @参数outputPath * @参数paramMapList *抛出:异常* / 私有静态无效addWatermark2_5(字符串路径,字符串inputPath,字符串outputPath,列表<地图<String,String >> paramMapList,String modeltype)抛出异常{ PdfReader pdfReader = new PdfReader(inputPath); FileOutputStream fileoutputStream = new FileOutputStream(outputPath);
PdfStamper pdfStamper = new PdfStamper(pdfReader,fileoutputStream); PdfContentByte content_yeardu = null; PdfContentByte content_continue_year = null; BaseFont basefont_kaiti = null; BaseFont basefont_songti = null; PdfGState pdfGstate = new PdfGState(); basefont_kaiti = BaseFont.createFont(path +“font / kaiti.TTF”,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED); basefont_songti = BaseFont.createFont(path +“font / songti.TTF”,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED); 尝试{ if(basefont_songti == null || basefont_kaiti == null){ throw new Exception(“生成打印pdf时,字体加载异常!!”); } //设置透明度为1.0不透明pdfGstate.setFillOpacity(1.0f);
int toPage = pdfStamper.getReader()。getNumberOfPages(); for(int i = 1; 我<= toPage; i ++){ Map <String,String> paremMap = paramMapList.get(i-1); if(StringUtils.isBlank(paremMap.get(“year_nd”))){ throw new Exception(“生成打印pdf时,解析传入参数时,发生异常,原因:参数year_nd为空值或者null,请检查!! “); } if(StringUtils.isBlank(paremMap.get(“continue_year”))){ throw new Exception(“生成打印pdf时,解析传入参数时,发生异常,原因:参数continue_year为空值或者null,请检查! !“); } //解析传入的参数String year_nd = paremMap.get(“year_nd”); String continue_year = paremMap.get(“continue_year”); content_yeardu = pdfStamper.getOverContent(i); content_yeardu.saveState(); content_yeardu.setGState(pdfGstate);
content_yeardu.beginText(); content_yeardu。
content_yeardu.setFontAndSize(basefont_kaiti,16); // // int yyy = 10 + 10 + 8; // int xxx = -30 + 11 + 6; // // int year_nd_x = 484 + 11 + 12 - 12; int continue_year_x = 624 + 11 + 12 - 12; int year_nd_y_And_continue_year_y = 0 + 10 + 17 + 17; //整体上下移动 if(“2”.equals(modeltype)){ content_yeardu.showTextAligned(Element.ALIGN_CENTER,year_nd,year_nd_x,355 + year_nd_y_And_continue_year_y,0); } else if(“3”.equals(modeltype)){ content_yeardu.showTextAligned(Element.ALIGN_CENTER,year_nd,year_nd_x,290 + year_nd_y_And_continue_year_y,0); } else if(“4”.equals(modeltype)){
content_yeardu.showTextAligned(Element.ALIGN_CENTER,year_nd,year_nd_x,225 + year_nd_y_And_continue_year_y,0); } else if(“5”.equals(modeltype)){ content_yeardu.showTextAligned(Element.ALIGN_CENTER,year_nd,year_nd_x,160 + year_nd_y_And_continue_year_y,0); } content_yeardu.endText(); content_continue_year = pdfStamper.getOverContent(i); content_continue_year.saveState(); content_continue_year.setGState(pdfGstate); content_continue_year.beginText(); content_continue_year.setColorFill(BaseColor.BLACK); content_continue_year.setFontAndSize(basefont_kaiti,18); 如果(“2” .equals(modeltype)){
content_continue_year.showTextAligned(Element.ALIGN_CENTER,“连续”+ continue_year +“年”,continue_year_x,355 + year_nd_y_And_continue_year_y,0); } else if(“3”.equals(modeltype)){ content_continue_year.showTextAligned(Element.ALIGN_CENTER,“连续”+ continue_year +“年”,continue_year_x,290 + year_nd_y_And_continue_year_y,0); } else if(“4”.equals(modeltype)){ content_continue_year.showTextAligned(Element.ALIGN_CENTER,“连续”+ continue_year +“年”,continue_year_x,225 + year_nd_y_And_continue_year_y,0); } else if(“5”.equals(modeltype)){ content_continue_year.showTextAligned(Element.ALIGN_CENTER,“连续”+ continue_year +“年”,continue_year_x,160 + year_nd_y_And_continue_year_y,0); } content_continue_year.endText(); }
} catch(Exception ex){ ex.printStackTrace(); 抛出新的例外(“生成打印pdf时,添加文字异常,请检查!!”,ex); } finally { content_yeardu = null; content_continue_year = null; basefont_kaiti = null; pdfStamper.close(); pdfReader.close(); fileoutputStream.close(); } } / ** *生成单个PDF文件* * @参数路径* @参数parMap * @参数moType * @返回* @throws异常* / 公共字符串createSinglePdf(字符串路径,地图<字符串,对象> parMap,字符串modeltype)抛出异常{ String pathStr =“”; FileOutputStream outfile = null; 文件文件= null;
PdfWriter mPdfWriter = null; try { // path =“C:// aa /”; BaseFont bfChinese = BaseFont.createFont(“STSongStd-Light”,“UniGB-UCS2-H”,false); Font font = new Font(bfChinese,12,Font.NORMAL); //设置字体大小//新文档(pageSize,marginLeft,marginRight,marginTop,marginBottom)document = new Document(PageSize.A4.rotate(),60,60,60,50 ); String filename = String.valueOf(new Date()。getTime()); pathStr = path + filename +“。pdf”; outfile = new FileOutputStream(pathStr); mPdfWriter = PdfWriter.getInstance(document,outfile); document.open(); // document.add(new Paragraph(“创建pdf文件。支持中文......”,字体)); document.add(new Paragraph(“”,font));
if(“1”.equals(modeltype)){ htmlStr = getHtml1(parMap); // htmlStr = getHtml22222(); } else if(“2”.equals(modeltype)){ htmlStr = getHtml2(parMap); } else if(“3”.equals(modeltype)){ htmlStr = getHtml3(parMap); } else if(“4”.equals(modeltype)){ htmlStr = getHtml4(parMap); } else if(“5”.equals(modeltype)){ htmlStr = getHtml5(parMap); } ByteArrayInputStream进行的仓=新ByteArrayInputStream的进行(htmlStr.getBytes(“UTF-8”)); XMLWorkerHelper.getInstance()。parseXHtml(mPdfWriter,document,bin,Charset.forName(“UTF-8”),new ChinaFontProvide()); catch(例外e){ e.printStackTrace(); 抛出新的例外(“
document.close(); mPdfWriter.close(); try { outfile.close(); } catch(IOException e){ e.printStackTrace(); } } 返回pathStr; } //读取请求传递过来的JSON格式数据,返回JSON字符串public static String readJSONData(HttpServletRequest request){ StringBuffer json = new StringBuffer(); String lineString = null; try { BufferedReader reader = request.getReader(); while((lineString = reader.readLine())!= null){ json.append(lineString); }上上 (例外五){ 的System.out.println(e.toString()); }
return json.toString(); } }
-
跨域在线批量展示pdf并且批量打印pdf
2018-09-21 10:35:20跨域在线批量展示pdf并且批量打印pdf,纯js实现,后台是自己本人写的servlet用http也可以.因为csdn只能每次上传一个资料 ,关于前端实现的也会在我的资料列表中上传. -
PDF批量解密加密解除限制
2018-10-27 17:57:15运行安装文件 执行注册机选中第一项生成KEY 然后注册。 -
战图全自动识别图框大小(含加长图框)批量打印PDFV2.2.rar
2020-08-13 14:49:09战图批量打印V2.2.12版,自动识别比例,准确率很高,优化绘图仪错误 支持图纸自动计算比例及查找图名图号 -
文件批量打印VB6.0源代码.rar
2019-07-10 11:56:59文件批量打印VB6.0源代码,只需选择批量打印的文件夹,就可进行批量打印了,这个例子对新手是相当 友好的,是一个容易理解的实例。 -
中望cad批量打印PDF(Dxf格式,打印范围为图形界限).exe
2021-09-08 18:57:04放在文件夹内运行,可把文件夹内dXF格式文件打印为pdf,注:打印范围为图形界限注:使用中望cad -
Excel批量打印PDF工具
2015-02-05 13:14:22格式相同数据库表格,通过VBA宏编程,批量Excel转pdf -
PDF批量打印软件
2015-05-10 05:48:40可以批量打印PDF,并且可以删除其中任意打印页,也可以改变打印页的顺序 -
跨域在线批量展示pdf并且打印pdf
2018-09-21 10:48:41跨域在线批量展示pdf并且批量打印pdf,前端我是用anuglar2技术做的.实际上,采用的是js+iframe实现的.可用于任何支持的平台.各位读者如何下载下来后,不能用可以私聊我 -
合并pdf文件-批量打印
2021-11-25 09:16:10有时候遇到需要批量打印pdf文件,或者需要将很多照片合并成一个pdf文件,就可以用这个软件 ,免费软件,文末有下载链接,操作步骤: 1、下载安装软件 2、打开软件 另存为一个总的pdf文件即可 软件下载地址 链接...展开全文 -
pdf批量打印机
2015-03-19 12:52:25批量打印CAD、word等文件转换成PDF -
CAD批量打印成PDF插件.zip
2020-01-15 15:08:40cad打印工具 cad打印工具 cad打印工具 cad打印工具 -
利用二次开发进行CAD批量打印探究.pdf
2021-08-04 00:01:00利用二次开发进行CAD批量打印探究.pdf -
Office批量打印精灵教程--Word、PDF、Excel、PPT批量打印
2021-04-26 12:28:14简介Office批量打印精灵是一款 Word、Excel、Powerpoint、PDF 等文档的批量打印软件。由于Office批量打印精灵4.0经过重新设计,相较于之前的版本3.1功能有大幅改进,所以这里不列举功能改进而直接列举常用功能。最新...简介
Office批量打印精灵是一款 Word、Excel、Powerpoint、PDF 等文档的批量打印软件。由于Office批量打印精灵4.0经过重新设计,相较于之前的版本3.1功能有大幅改进,所以这里不列举功能改进而直接列举常用功能。最新版可到依云软件官网下载。
主界面:
软件操作简单,打开软件,拖放文件或文件夹到列表,选择打印机,点“开始打印”即可自动批量打印并统计页数,也可点“统计页数”不打印仅统计页数。
如上演示Office批量打印精灵非常容易上手,但要满足各类需求需要一些强大的功能,下面列举了一些常用的功能:
添加文件或文件夹
可拖放文件到列表,列表文件排序与操作系统中的相同:
可拖放文件夹下的所有文件到列表:
过滤选项可设置添加指定类型的文件到列表,下面设置只添加 word 文件,当拖放的文件或文件包含其他类型也不会添加到列表:
含子文件夹选项
默认是勾选的,拖放文件夹时子文件下的文件也将添加到列表。
当勾选直接添加文件夹
时,将直接添加文件夹到列表,在打印或计算页数前自动展开,
排序
列表中的顺序及打印顺序,列表默认排序与操作系统资源管理器文件名的升序排序方式相同,添加文件后可点击任意表头(序号除外)对整个列表升序或降序排序:
可拖放单行,连续多行,非连续多行改变顺序:
可将单行、连续多行,非连续多行上移、下移或删除:
导出结果
打印或统计页数完成后,可点“导出结果”按钮,导出 .csv 格式文件,可用 Excel 打开对其数据进行分析:
设置条目
可在文件或文件夹添加到列表后设置条目:
是否包含子文件夹:此选项仅对文件夹有效
打印页码范围,对各种类型的文档(Word、PDF、Excel、PPT)都可设置,单部分设置类型只能用于特定类型文档,设置模式及用例:
单页 1
连续多页 2-4
连续多页逆序打印 5-3
倒数模式,倒数第三页至倒数第一页 L3-L1
倒数逆序模式,倒数第一页至倒数第三页 L1-L3
正数倒数结合模式,第二页至倒数第二页 1-L2
需说明:
使用逗号连接各页面范围 1,2-4,5-3,L3-L1,L1-L3,1-L2
各页码范围重叠的部分也会被分别打印,如 1,1-2 第一页将打印 2 次
其中 Word、PPT 文档支持全部模式
其中 Excel 文档只支持连续非逆序页码,另外支持只打印默认 Sheet,或依据名称或索引只打印某些 Sheet
其中 PDF 文档:
Internal 引擎支持除逆序外的模式
Adobe 1 引擎支持全部模式
Adobe 2 引擎仅支持打印全部页码
奇数页或偶数页:可打印上述页面范围的所有也或仅打印奇数或偶数页
双面打印:可使用打印机默认设置或指定双面打印模式,指定双面打印模式需要打印机支持
份数:可指定打印份数
备注:设置备注不会影响打印
选项
当设置选项后添加文件时会应用 打印页码范围、奇数页或偶数页、双面打印、份数到列表,其它设置在添加文档前后设置效果是一样的。
基本选项
Word 选项
PDF 选项
Excel 选项
PPT 选项
-
批量打印页面数据
2014-09-09 15:21:41批量打印页面数据 -
前端连接打印机批量打印pdf格式的文件
2021-06-20 01:43:54} </style> 批量打印</button> <table> <thead> <tr> <th> <input type="checkbox" id="j_cbAll" /> </th> 节日</th> 月份</th> </tr> </thead> <tbody id="j_tb"> <tr class="usePrint"> <td> ... -
python 批量打印PDF(转)
2022-02-25 21:27:46有一批PDF文件,好几百个,每个只打印第2,3页,双面打印。 网上搜索一波,方案如下: 安装Ghostscript,GhostView,使用gsprint命令打印pdf文件。 gsprint命令参数说明: "-dQUIET", 安静的意思,指代执行过程... -
网页批量打印成PDF,并按条件合并成大PDF、生成页码
2021-06-19 04:20:29合同在系统(web系统)中以html形式显示,打印单份都是在网页中右键打印,订单量上千份,每笔订单有两份合同,如果手动打印的话,需要打印2000+次,因为还要按月份进行整理,还要页码,所以先要保存成PDF(因为有电子... -
批量打印成PDF时不用每次点击保存位置的技巧
2021-06-19 04:18:01把SolidWorks工程图转成PDF有两种方式,一种方式是直接转换PDF,另一种方式是通过PDF虚拟打印机打印成PDF。我们一般推荐使用第一种方式,一般除了可能会遇到一些字体问题,没有别的缺点。而打印成PDF的方式在速度,... -
批量打印(excel).exe
2020-11-30 15:41:12基于vb开发的批量打印excel文件的独立运行程序,点击获取打印机列表之后,可以在列表框中选择所需打印机,点击批量打印之后程序调用相应打印机的驱动对所选的excel文件进行批量打印 -
批量打印 Office批量打印精灵 v4.0
2020-10-17 17:04:42Office批量打印精灵支持Word、Excel、PowerPoint、PDF等文档的批量打印,且可使用虚拟打印机将单个Office文档转换为单个PDF文档。支持多种格式Office文档的批量打印:支持Word格式:*.docx、*