tronds

Bokhylla Downloader: Unused code

Jan 6th, 2014
227
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1.     public void loadLocalImages( int startPage, int endPage, String inputPrefix) throws IOException, DocumentException{
  2.        
  3.         //BufferedImage[] images = new BufferedImage[endPage + 1];
  4.        
  5.         Document document = new Document();
  6.         PdfWriter.getInstance(document,
  7.             new FileOutputStream("VictoriaInversed.pdf"));
  8.         document.open();
  9.        
  10.         document.right(0);
  11.         document.left(0);
  12.         document.setMargins(0, 0, 0, 0);
  13.         document.compress = true;
  14.        
  15.         URL imageURL = new URL("http://stat.ks.kidsklik.com/statics/files/2011/02/12967198191354791838.jpg");
  16.        
  17.         for(int i = startPage; i <= endPage; i++){
  18.                
  19.             imageURL = new URL(inputPrefix + i + ".png");
  20.            
  21.             //document.add(new Paragraph("\n"+"AWT Image"));
  22.             java.awt.image.BufferedImage awtImg = ImageIO.read(imageURL);
  23.             awtImg = invertImage(awtImg);
  24.             Image image =
  25.                 Image.getInstance(awtImg, null);
  26.             image.setAbsolutePosition(0f, 0f);
  27.             image.scaleToFit(document.getPageSize());
  28.             document.add(image);
  29.             document.newPage();
  30.            
  31.         }
  32.        
  33.         document.close();
  34.     }
  35.    
  36.     public void saveImages(BufferedImage[] img, String outputPrefix) throws IOException{
  37.         int i = 0;
  38.         for(BufferedImage k : img){
  39.             ImageIO.write(k, "png", new File(outputPrefix + i + ".png"));
  40.             i++;
  41.         }
  42.     }
  43.    
  44.     public void savePDFDocument(BufferedImage[] images, String outputFile) throws DocumentException, MalformedURLException, IOException{
  45.        
  46.        
  47.         Document document = new Document();
  48.         PdfWriter.getInstance(document,
  49.             new FileOutputStream(outputFile));
  50.         document.open();
  51.        
  52.         for(BufferedImage img : images){
  53.            
  54.             document.add(new Paragraph("\n"+"AWT Image"));
  55.             java.awt.Image awtImg = img;
  56.             Image image =
  57.                 Image.getInstance(awtImg, null);
  58.             document.add(image);
  59.             document.newPage();
  60.         }          
  61.        
  62.         document.close();
  63.     }
Comments
  • Comment was deleted
Add Comment
Please, Sign In to add comment