中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

怎樣注冊公司流程山西seo優(yōu)化公司

怎樣注冊公司流程,山西seo優(yōu)化公司,寧波大型網(wǎng)站建設(shè),深圳寶安區(qū)是市中心嗎優(yōu)化方法一:使用PdfSmartCopy類代替PdfCopy類。這個類可以在合并PDF文件時,檢測并消除重復(fù)的對象,從而減少內(nèi)存的占用。您可以參考以下代碼示例: //創(chuàng)建一個Document對象 Document document new Document();//創(chuàng)建一個PdfSmartC…
  • 優(yōu)化方法一:使用PdfSmartCopy類代替PdfCopy類。這個類可以在合并PDF文件時,檢測并消除重復(fù)的對象,從而減少內(nèi)存的占用。您可以參考以下代碼示例:
//創(chuàng)建一個Document對象
Document document = new Document();//創(chuàng)建一個PdfSmartCopy對象
PdfSmartCopy copy = new PdfSmartCopy(document, new FileOutputStream("output.pdf"));//打開Document對象
document.open();//創(chuàng)建一個PdfReader對象
PdfReader reader = null;//遍歷要合并的PDF文件
for (String file : files) {//加載PDF文件reader = new PdfReader(file);//獲取PDF文件的總頁數(shù)int n = reader.getNumberOfPages();//遍歷每一頁,添加到PdfSmartCopy對象中for (int page = 0; page < n;) {copy.addPage(copy.getImportedPage(reader, ++page));}
}//關(guān)閉PdfReader對象
reader.close();//關(guān)閉Document對象
document.close();//創(chuàng)建一個PdfStamper對象
PdfStamper stamper = new PdfStamper(new PdfReader("output.pdf"), new FileOutputStream("output.pdf"));//獲取總頁數(shù)
int pageCount = stamper.getReader().getNumberOfPages();//遍歷每一頁,添加頁碼
for (int i = 1; i <= pageCount; i++) {//獲取當(dāng)前頁PdfContentByte content = stamper.getOverContent(i);//設(shè)置字體和顏色content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12);content.setRGBColorFill(0, 0, 0);//獲取當(dāng)前頁的寬度和高度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();
}//關(guān)閉PdfStamper對象
stamper.close();
  • 優(yōu)化方法二:使用PdfWriter類代替PdfCopy類。這個類可以在合并PDF文件時,直接將每一頁寫入到輸出流中,而不需要將整個文檔加載到內(nèi)存中??梢詤⒖家韵麓a示例:
//創(chuàng)建一個Document對象
Document document = new Document();//創(chuàng)建一個PdfWriter對象
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));//打開Document對象
document.open();//創(chuàng)建一個PdfImportedPage對象
PdfImportedPage page = null;//創(chuàng)建一個PdfReader對象
PdfReader reader = null;//遍歷要合并的PDF文件
for (String file : files) {//加載PDF文件reader = new PdfReader(file);//獲取PDF文件的總頁數(shù)int n = reader.getNumberOfPages();//遍歷每一頁,添加到PdfWriter對象中for (int i = 1; i <= n; i++) {//獲取當(dāng)前頁的寬度和高度Rectangle pageSize = reader.getPageSizeWithRotation(i);float width = pageSize.getWidth();float height = pageSize.getHeight();//設(shè)置Document對象的頁面大小document.setPageSize(pageSize);//創(chuàng)建一個新的頁面document.newPage();//導(dǎo)入當(dāng)前頁page = writer.getImportedPage(reader, i);//將當(dāng)前頁添加到PdfWriter對象中writer.addPageDictEntry(PdfName.ROTATE, pageSize.getRotationAsPageDictEntry());writer.addDirectImageSimple(page);writer.getCurrentPage().add(page);//創(chuàng)建一個PdfContentByte對象PdfContentByte content = writer.getDirectContent();//設(shè)置字體和顏色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();}
}//關(guān)閉PdfReader對象
reader.close();//關(guān)閉Document對象
document.close();
  • 優(yōu)化方法三:使用PdfReader類的partial和selectPages方法。這些方法可以在加載PDF文件時,只讀取需要的頁面,而不需要將整個文檔加載到內(nèi)存中??梢詤⒖家韵麓a示例:
//創(chuàng)建一個Document對象
Document document = new Document();//創(chuàng)建一個PdfCopy對象
PdfCopy copy = new PdfCopy(document, new FileOutputStream("output.pdf"));//打開Document對象
document.open();//創(chuàng)建一個PdfReader對象
PdfReader reader = null;//遍歷要合并的PDF文件
for (String file : files) {//設(shè)置partial為true,只讀取需要的頁面reader = new PdfReader(new RandomAccessFileOrArray(file), null);reader.consolidateNamedDestinations();reader.partial = true;//獲取PDF文件的總頁數(shù)int n = reader.getNumberOfPages();//創(chuàng)建一個List對象,存儲需要的頁面List<Integer> pages = new ArrayList<Integer>();//遍歷每一頁,添加到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));}
}//關(guān)閉PdfReader對象
reader.close();//關(guān)閉Document對象
document.close();//創(chuàng)建一個PdfStamper對象
PdfStamper stamper = new PdfStamper(new PdfReader("output.pdf"), new FileOutputStream("output.pdf"));//獲取總頁數(shù)
int pageCount = stamper.getReader().getNumberOfPages();//遍歷每一頁,添加頁碼
for (int i = 1; i <= pageCount; i++) {//獲取當(dāng)前頁PdfContentByte content = stamper.getOverContent(i);//設(shè)置字體和顏色content.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED), 12);content.setRGBColorFill(0, 0, 0);//獲取當(dāng)前頁的寬度和高度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();
}//關(guān)閉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.risenshineclean.com/news/55287.html

相關(guān)文章:

  • 手機上如何寫html網(wǎng)頁seo搜索引擎優(yōu)化就業(yè)前景
  • 怎樣在商務(wù)部網(wǎng)站做備案小學(xué)生抄寫新聞20字
  • wordpress qq登錄seo顧問咨詢
  • 論壇怎么做網(wǎng)站鏈接廣告聯(lián)盟廣告點擊一次多少錢
  • 專業(yè)做加盟推廣的公司百度網(wǎng)站的優(yōu)化方案
  • 營銷型手機網(wǎng)站建設(shè)重慶網(wǎng)站seo搜索引擎優(yōu)化
  • 直播網(wǎng)站源碼免費網(wǎng)站建設(shè)技術(shù)托管
  • 對于職業(yè)規(guī)劃做的好的網(wǎng)站seo網(wǎng)站建設(shè)
  • ps如何做psd模板下載網(wǎng)站南京疫情最新消息
  • 南京網(wǎng)站建設(shè)推廣域名搜索
  • 做時時彩開獎網(wǎng)站犯法嗎aso關(guān)鍵詞優(yōu)化工具
  • 百度推廣方式武漢seo優(yōu)化代理
  • 考試網(wǎng)站模版河北網(wǎng)站建設(shè)制作
  • 優(yōu)購物官方網(wǎng)站化妝品搜狗站長推送工具
  • 百度競價排名收費標(biāo)準(zhǔn)長沙正規(guī)競價優(yōu)化服務(wù)
  • 網(wǎng)站導(dǎo)航css源代碼seo多久可以學(xué)會
  • 互聯(lián)網(wǎng)推廣服務(wù)長沙seo 優(yōu)化選智投未來no1
  • 最新疫情防控方案家庭優(yōu)化大師免費下載
  • 建設(shè)網(wǎng)站公開教學(xué)視頻下載網(wǎng)絡(luò)網(wǎng)站推廣
  • 做測試的網(wǎng)站有哪些免費網(wǎng)絡(luò)推廣平臺
  • 一品威客做的網(wǎng)站好用嗎網(wǎng)站快速優(yōu)化排名軟件
  • 做個網(wǎng)站要多少錢福州seo網(wǎng)站排名
  • 網(wǎng)頁設(shè)計模板套用步驟seo網(wǎng)絡(luò)搜索引擎優(yōu)化
  • 網(wǎng)站常用模塊百度在線問答
  • 公司建網(wǎng)站做app要多少錢精準(zhǔn)網(wǎng)絡(luò)推廣
  • 專業(yè)電容層析成像代做網(wǎng)站排名檢測
  • 網(wǎng)頁制作與網(wǎng)站開發(fā)模板今日頭條新聞大事件
  • wordpress和bootstrap廣東seo網(wǎng)站優(yōu)化公司
  • 哪里做網(wǎng)站做得好免費網(wǎng)站收錄網(wǎng)站推廣
  • html5營銷網(wǎng)站建設(shè)app推廣注冊接單平臺