当前位置: 首页 > news >正文

建筑资料网站有哪些o2o模式是什么意思

建筑资料网站有哪些,o2o模式是什么意思,wordpress电子商务插件,wordpress 虚拟数据优化方法一#xff1a;使用PdfSmartCopy类代替PdfCopy类。这个类可以在合并PDF文件时#xff0c;检测并消除重复的对象#xff0c;从而减少内存的占用。您可以参考以下代码示例#xff1a; //创建一个Document对象 Document document new Document();//创建一个PdfSmartC…优化方法一使用PdfSmartCopy类代替PdfCopy类。这个类可以在合并PDF文件时检测并消除重复的对象从而减少内存的占用。您可以参考以下代码示例 //创建一个Document对象 Document document new Document();//创建一个PdfSmartCopy对象 PdfSmartCopy copy new PdfSmartCopy(document, new FileOutputStream(output.pdf));//打开Document对象 document.open();//创建一个PdfReader对象 PdfReader reader null;//遍历要合并的PDF文件 for (String file : files) {//加载PDF文件reader new PdfReader(file);//获取PDF文件的总页数int n reader.getNumberOfPages();//遍历每一页添加到PdfSmartCopy对象中for (int page 0; page n;) {copy.addPage(copy.getImportedPage(reader, page));} }//关闭PdfReader对象 reader.close();//关闭Document对象 document.close();//创建一个PdfStamper对象 PdfStamper stamper new PdfStamper(new PdfReader(output.pdf), new FileOutputStream(output.pdf));//获取总页数 int pageCount stamper.getReader().getNumberOfPages();//遍历每一页添加页码 for (int i 1; i pageCount; i) {//获取当前页PdfContentByte content stamper.getOverContent(i);//设置字体和颜色content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12);content.setRGBColorFill(0, 0, 0);//获取当前页的宽度和高度Rectangle pageSize stamper.getReader().getPageSize(i);float width pageSize.getWidth();float height pageSize.getHeight();//计算页码的位置float x width / 2;float y 10;//添加页码content.beginText();content.showTextAligned(PdfContentByte.ALIGN_CENTER, 第 i 页共 pageCount 页, x, y, 0);content.endText(); }//关闭PdfStamper对象 stamper.close();优化方法二使用PdfWriter类代替PdfCopy类。这个类可以在合并PDF文件时直接将每一页写入到输出流中而不需要将整个文档加载到内存中。可以参考以下代码示例 //创建一个Document对象 Document document new Document();//创建一个PdfWriter对象 PdfWriter writer PdfWriter.getInstance(document, new FileOutputStream(output.pdf));//打开Document对象 document.open();//创建一个PdfImportedPage对象 PdfImportedPage page null;//创建一个PdfReader对象 PdfReader reader null;//遍历要合并的PDF文件 for (String file : files) {//加载PDF文件reader new PdfReader(file);//获取PDF文件的总页数int n reader.getNumberOfPages();//遍历每一页添加到PdfWriter对象中for (int i 1; i n; i) {//获取当前页的宽度和高度Rectangle pageSize reader.getPageSizeWithRotation(i);float width pageSize.getWidth();float height pageSize.getHeight();//设置Document对象的页面大小document.setPageSize(pageSize);//创建一个新的页面document.newPage();//导入当前页page writer.getImportedPage(reader, i);//将当前页添加到PdfWriter对象中writer.addPageDictEntry(PdfName.ROTATE, pageSize.getRotationAsPageDictEntry());writer.addDirectImageSimple(page);writer.getCurrentPage().add(page);//创建一个PdfContentByte对象PdfContentByte content writer.getDirectContent();//设置字体和颜色content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12);content.setRGBColorFill(0, 0, 0);//计算页码的位置float x width / 2;float y 10;//添加页码content.beginText();content.showTextAligned(PdfContentByte.ALIGN_CENTER, 第 i 页共 pageCount 页, x, y, 0);content.endText();} }//关闭PdfReader对象 reader.close();//关闭Document对象 document.close(); 优化方法三使用PdfReader类的partial和selectPages方法。这些方法可以在加载PDF文件时只读取需要的页面而不需要将整个文档加载到内存中。可以参考以下代码示例 //创建一个Document对象 Document document new Document();//创建一个PdfCopy对象 PdfCopy copy new PdfCopy(document, new FileOutputStream(output.pdf));//打开Document对象 document.open();//创建一个PdfReader对象 PdfReader reader null;//遍历要合并的PDF文件 for (String file : files) {//设置partial为true只读取需要的页面reader new PdfReader(new RandomAccessFileOrArray(file), null);reader.consolidateNamedDestinations();reader.partial true;//获取PDF文件的总页数int n reader.getNumberOfPages();//创建一个List对象存储需要的页面ListInteger pages new ArrayListInteger();//遍历每一页添加到List对象中for (int i 1; i n; i) {pages.add(i);}//使用selectPages方法只选择需要的页面reader.selectPages(pages);//将选择的页面添加到PdfCopy对象中for (int i 0; i pages.size(); ) {copy.addPage(copy.getImportedPage(reader, i));} }//关闭PdfReader对象 reader.close();//关闭Document对象 document.close();//创建一个PdfStamper对象 PdfStamper stamper new PdfStamper(new PdfReader(output.pdf), new FileOutputStream(output.pdf));//获取总页数 int pageCount stamper.getReader().getNumberOfPages();//遍历每一页添加页码 for (int i 1; i pageCount; i) {//获取当前页PdfContentByte content stamper.getOverContent(i);//设置字体和颜色content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12);content.setRGBColorFill(0, 0, 0);//获取当前页的宽度和高度Rectangle pageSize stamper.getReader().getPageSize(i);float width pageSize.getWidth();float height pageSize.getHeight();//计算页码的位置float x width / 2;float y 10;//添加页码content.beginText();content.showTextAligned(PdfContentByte.ALIGN_CENTER, 第 i 页共 pageCount 页, x, y, 0);content.endText(); }//关闭PdfStamper对象 stamper.close();[java - How to avoid OutOfMemoryError when merging PDFs using iText? - Stack Overflow] [java - How to merge pdf files without loading all the documents in memory? - Stack Overflow] [java - How to merge pdf files without loading all the documents in memory? - Stack Overflow]
http://www.zqtcl.cn/news/506719/

相关文章:

  • 哈尔滨住房和城乡建设厅网站公司网站建设 费用入账
  • 网站图片缩略图t恤图案设计网站
  • 对招聘网站页面设计做建议网站流量 转化率
  • 怎么样做网站注册量郴州市北湖区
  • 山东企业展厅设计公司济南网站建设优化公司
  • 什么网站免费做游戏工艺品外贸订单网
  • 免费推广网站制作网站设计的技术有
  • 深圳电商网站建设高校学风建设专栏网站
  • 品牌网站建设 2蝌蚪小三网合一的网站怎么做
  • 对二次网站开发的认识wordpress修改图片大小
  • 电商网站项目建设个人网站空间收费
  • 官方网站制作思路樟木头东莞网站建设
  • 怎么寻找做有益做网站的客户大连网站推广
  • 湖南网站开发企业excel网站建设
  • 安康网站建设技巧腾讯建设网站视频下载
  • 如何能让企业做网站的打算中企动力做网站贵吗
  • wordpress 空间常州seo
  • 网站负责人备案采集照具体要求湛江网吧
  • 长春建站模板制作php网站空间购买
  • 网站域名到期怎么办食品包装设计的介绍
  • 建设网站专栏台州cms模板建站
  • 网站建设套餐方案湛江网站如何制作
  • wordpress网站怎么打开西安企业做网站多少钱
  • 电子商务网站建设的实训报告网页美工设计夏霍
  • 在一呼百应上做网站行吗江西省住房和城乡建设厅的网站
  • 对百度网站进行分析山水人家装饰公司
  • 接网站开发广州仿站定制模板建站
  • 资源网站源码下载制作软件的app有哪些
  • 免备案空间网站电子商务网站经营特色分析的主要内容包括
  • 遨游建站网站设计的基本知识