Merging the pdf files are very simple. Before you workout this you should download the "pdfbox" jar. The coding is as belows.
import org.apache.pdfbox.util.PDFMergerUtility;
public class MergePDF {
public static void main(String[] args) {
try {
String SFilePath = "d://Merge//";
PDFMergerUtility ut = new PDFMergerUtility();
ut.addSource(SFilePath+"1.pdf");
ut.addSource(SFilePath+"2.pdf");
ut.addSource(SFilePath+"3.pdf");
ut.addSource(SFilePath+"4.pdf");
ut.setDestinationFileName(SFilePath+"Merge.pdf");
ut.mergeDocuments();
}catch(Exception ex) {
ex.printStackTrace();
}
}
}
import org.apache.pdfbox.util.PDFMergerUtility;
public class MergePDF {
public static void main(String[] args) {
try {
String SFilePath = "d://Merge//";
PDFMergerUtility ut = new PDFMergerUtility();
ut.addSource(SFilePath+"1.pdf");
ut.addSource(SFilePath+"2.pdf");
ut.addSource(SFilePath+"3.pdf");
ut.addSource(SFilePath+"4.pdf");
ut.setDestinationFileName(SFilePath+"Merge.pdf");
ut.mergeDocuments();
}catch(Exception ex) {
ex.printStackTrace();
}
}
}
No comments:
Post a Comment