Wednesday, October 10, 2012

PDFBOX Merging Multiple PDF

PDFBox is providing excellent support for merging multiple PDF files into one. You just need to add following jars in your project and use below code to merge multiple pdfs 1. PDFBox.jar 2. apache-common-logging Ref:http://java.dzone.com/news/merging-pdf%E2%80%99s-with-pdfbox
/**
     * SyntaxHighlighter
     */
import java.io.File;
import java.io.IOException;
import java.util.UUID;

import org.apache.pdfbox.exceptions.COSVisitorException;
import org.apache.pdfbox.util.PDFMergerUtility;


public class PDFMergeTest {
 public static void main(String args[]) throws COSVisitorException, IOException{
  PDFMergerUtility mergePdf = new PDFMergerUtility();
  String folder="D:\\sample";
  String numberOfFiles[]=getFiles(folder);
  for(int i = 0; i < numberOfFiles.length; i++){
   mergePdf.addSource(folder + File.separator + numberOfFiles[i]);
   System.out.println(numberOfFiles[i]);
  }
  mergePdf.setDestinationFileName(folder + File.separator + "final.pdf");
  mergePdf.mergeDocuments();
  
 }

 private static String[] getFiles(String folder) throws IOException
 {
  File _folder = new File(folder);
  String[] filesInFolder;   

  if(_folder.isDirectory())
  {
   filesInFolder = _folder.list();
   return filesInFolder;
  }
  else
  {
   throw new IOException("Path is not a directory");
  }
 }
}

Sunday, March 6, 2011

How to Create CD to ISO Image File on Linux

  It is so simple .To create iso image file from linux, you don’t need any software. It can be done by only just one command on terminal

 

cat /dev/scd0 > /home/haroon/ubuntu.iso



Reference



http://www.tech-recipes.com/rx/2769/ubuntu_how_to_create_iso_image_from_cd_dvd/





Monday, November 29, 2010