JAVA開発メモ
PDFBox のバックアップ差分(No.5)
 

[トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]













  
  *NEWS



  


  


   String readFile = "xxx.pdf";

   FileInputStream pdfStream = null;
   try {
       pdfStream = new FileInputStream(readFile);
       PDFParser pdfParser = new PDFParser(pdfStream);

       pdf = pdfParser.getPDDocument();
   } catch (Exception e) {
       e.printStackTrace();
   } finally {
       if (pdfStream != null) {
           pdfStream.close();
       }
   }
  

   String writeFile = "xxx.pdf";
   COSWriter writer = null;
   FileOutputStream stream = null;
   try {
       stream = new FileOutputStream(writeFile);
       writer = new COSWriter(stream);

   } catch (Exception e) {
       e.printStackTrace();
   } finally {
       if (stream != null) {
           stream.close();
       }
       if (writer != null) {
           writer.close();
       }
   }
  



   PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
   PDAcroForm acroForm = docCatalog.getAcroForm();

   if (field != null) {

   } else {

   }
  

   String readFile = "C:\\tmp\\Antenna_Data_Sheet.pdf";

   FileInputStream pdfStream = null;
   try {
       pdfStream = new FileInputStream(readFile);
       PDFParser pdfParser = new PDFParser(pdfStream);

       pdf = pdfParser.getPDDocument();
       int imageCounter = 1;
       List pages = pdf.getDocumentCatalog().getAllPages();
       Iterator iter = pages.iterator();

           PDPage page = (PDPage) iter.next();
           PDResources resources = page.getResources();
           Map images = resources.getImages();
           if (images != null) {
               Iterator imageIter = images.keySet().iterator();
               while (imageIter.hasNext()) {
                   String key = (String) imageIter.next();
                   PDXObjectImage image = (PDXObjectImage) images.get(key);
                   String name = key + "-" + imageCounter;
                   imageCounter++;
                   System.out.println("Writing image:" + name);

               }
           }
       }
   } catch (Exception e) {
       e.printStackTrace();
   } finally {
       if (pdfStream != null) {
           pdfStream.close();
       }
   }
  

トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.33

HTML convert time to 0.006 sec.