Hi,

I have been trying one example with PDFBox to merge two pdfs using 
PDFMergerUtility class.

/*---- code snippet  ---*/

PDFMergerUtility mergePdf = new PDFMergerUtility();
mergePdf.addSource(file1);
mergePdf.addSource(file2);
mergePdf.setDestinationFileName(file3);
try {
mergePdf.mergeDocuments();
} catch (COSVisitorException e) {
throw new InsolveException(e);
} catch (IOException e) {
e.printStackTrace();
throw new InsolveException(e);
}

/*---- code snippet --- */

When I use the above code in a standalone application it is merging two pdf 
files properly.

But when I use the above function in a web application as a server side program 
and deployed to Tomcat, the mergeDocuments() statement is causing the following 
exception.

Exception print stack trace:

java.io.IOException: The system cannot find the path specified
                at java.io.WinNTFileSystem.createFileExclusively(Native Method)
                at java.io.File.checkAndCreate(Unknown Source)
                at java.io.File.createTempFile(Unknown Source)
                at 
org.apache.pdfbox.cos.COSDocument.<init>(COSDocument.java:103)
                at org.apache.pdfbox.cos.COSDocument.<init>(COSDocument.java:90)
                at 
org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:153)
                at 
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:841)
                at 
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:808)
                at 
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:779)
                at 
org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:127)
                at com.insolve.common.Utility.mergePDFS(Utility.java:503)

Note: all the files and folders are available in the file system according to 
the given paths.

I am guessing there could be some problem with Windows file system which is not 
allowing to create a file from PDFBox code.
Please let me know what could be the reason and how to solve it.

Thanks in advance,
Balakrishna.
DISCLAIMER:

This email message and all attachments are  confidential and may contain 
information that
is privileged,  confidential or exempt from  disclosure under applicable law.  
If you are
not  the intended  recipient,  you  are notified  that any dissemination, 
distribution or 
copying  of this email  is strictly prohibited. If you have received this email 
in error, 
please notify us immediately by return email or to [email protected] 
and destroy 
the original message.

Opinions, conclusions, and other  information in  this message that  do not 
relate to the 
official business of SPAN, shall be understood to be neither given nor endorsed 
by SPAN.

Reply via email to