I have several pdf files and I want to create a single pdf file containing these files.
How could i do ?
regards
Xavier Sola
I have several pdf files and I want to create a single pdf file containing these files.
How could i do ?
regards
Xavier Sola
Use Apache PDFBox library to achieve the same. You have to write Java service to invoke their APIs. Below is a sample URL for starters.
Using PDFBox from the samples on their page.
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String[] filenames = IDataUtil.getStringArray( pipelineCursor, "filenames" );
pipelineCursor.destroy();
PDFMergerUtility mergePdf = new PDFMergerUtility();
try {
for(int i=0;i<filenames.length;i++){
File file=new File(filenames[i]);
String destFileName=file.getName();
mergePdf.addSource(file);
}
mergePdf.setDestinationFileName("test.pdf");
mergePdf.mergeDocuments();
} catch (COSVisitorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
IDataUtil.put( pipelineCursor, "error", e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
IDataUtil.put( pipelineCursor, "error", e.toString());
}