[
https://issues.apache.org/jira/browse/PDFBOX-1318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
John Hewson closed PDFBOX-1318.
-------------------------------
Resolution: Invalid
> Stops when writing images to a large file
> -----------------------------------------
>
> Key: PDFBOX-1318
> URL: https://issues.apache.org/jira/browse/PDFBOX-1318
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.6.0
> Environment: Tested on Ubuntu 11.10 1.7 GB memory AMD Dual Core
> QL-60x2, OS 10.7.4 iMac 4GB Quad 2.66 GHz i5, XP64 SP2 iMac 4GB Quad 2.66 GHz
> i5
> Reporter: DWiebe
>
> When writing images to a large pdf, it stops after some amount of images (the
> size depends on the machine) when creating a PDJpeg object.
> public void processFiles(File parent){
> int fileIndex = 1;
> for(ImageGroup g:allImages){
> int i = 0;
> int fileCount = 0;
> int imgCount = 0;
> PDDocument acrobat = null;
> String groupPath =
> parent.getAbsolutePath()+"/"+g.getName();
> File groupFolder = new File(groupPath);
>
> try{
> acrobat = new PDDocument();
>
> groupFolder.mkdir();
> }catch(Exception e){
> continue;
> }
> for(File f:g.getImages()){
> //set progress bar and text
> bar.setValue(fileIndex);
> currentStatus.setText("Currently processing
> "+fileIndex+" of "+totalFiles);
> System.out.println("Currently processing
> "+f.getName()+" "+fileIndex+" of "+totalFiles);
> this.pack();
> this.setVisible(true);
> this.repaint();
>
> PDPageContentStream contentStream = null;
>
> try{
> //pull image
> BufferedImage bigImage =
> ImageIO.read(f);
> int w = bigImage.getWidth();
> int h = bigImage.getHeight();
> //create page of image size
> PDRectangle rect = new PDRectangle(w,
> h);
> PDPage page = new PDPage(rect);
> acrobat.addPage(page);
> //draw image
> //THE PROGRAM STOPS HERE
> PDJpeg img = new PDJpeg(acrobat,
> bigImage);
>
> //the rest of drawing the image
> contentStream = new
> PDPageContentStream(acrobat,page);
> contentStream.drawImage(img, 0, 0);
> contentStream.close();
> //acrobat.save(groupPath+".pdf");
> //acrobat.close();
> //File result = new
> File(groupPath+".pdf");
> //acrobat = PDDocument.load(result);
>
> //copy image in case the user needs it.
> imgCount++;
> if(imgCount > Constants.MAX_FILE){
> acrobat.save(groupPath+".pdf");
> groupPath += "_"+fileCount;
> File excessFolder = new
> File(groupPath);
> fileCount++;
> imgCount = 0;
> try{
> acrobat = new PDDocument();
>
> excessFolder.mkdir();
> }catch(Exception e){
>
> }
> }
> }catch(Exception e){
> e.printStackTrace();
> }
>
> this.copyFile(f,
> groupPath+"/"+g.getName()+"_"+i+".jpg");
> i++;
> fileIndex++;
> }
> try {
> acrobat.save(groupPath+".pdf");
> acrobat.close();
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> currentStatus.setText("Your images have been copied
> successfully");
> this.pack();
> this.repaint();
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)