Hi,
We are facing a big problem with saving a newly created pdf file to a network folder. The matter has now reached critical level. The file is a new file into which we merge our converted Pdf documents. The convertions work and can save to the network location (same location and folder even) but as soon as we attempt to save the merged file to the location we get a Java access denied error. When we run the same command locally on that server there is no problem and it works perfect. This was also working under Windows Server 2012 without any problems but since the OS upgrade it has failed to work. We have exhausted all avenues with OS support to resolve the issue and both Java versions and the OS permissions had been reconfirmed as full admin rights.
Code below:
File dir = new File(sourceFolder);
File[] directoryListing = dir.listFiles();
if (directoryListing != null) {
Arrays.sort(directoryListing);
File f = new File(outputFile);
if (!f.exists() && !f.isDirectory()) {
Document newMergedPDF = new Document();
newMergedPDF.save(outputFile);
newMergedPDF.close();
}else {
f.delete();
Document newMergedPDF = new Document();
newMergedPDF.save(outputFile);
newMergedPDF.close();
}
Document mergedPDF = new Document(outputFile);
for (File child : directoryListing) {
if (child.toString().toLowerCase().endsWith(".pdf")) {
System.out.println("Processing file " + child);
try {
OptimizationOptions opt = new OptimizationOptions();
opt.setCompressImages(true);
opt.setImageQuality(50);
opt.setMaxResoultion(150);
opt.setRemoveUnusedObjects(true);
opt.setRemoveUnusedStreams(true);
opt.setResizeImages(true);
mergedPDF.optimize();
mergedPDF.optimizeResources(opt);
if (preview.equalsIgnoreCase("X")) {
System.out.println(bundle.getString("TEXT11"));
DocumentPrivilege privilege = DocumentPrivilege.getForbidAll();
mergedPDF.encrypt("", "", privilege, CryptoAlgorithm.AESx128, false);
}
Document existingPDF = new Document(child.getAbsolutePath());
if (watermark.equalsIgnoreCase("X")) {
System.out.println(bundle.getString("TEXT12"));
AddWaterMark waterMark = new AddWaterMark();
waterMark.addWaterMark(existingPDF, waterMarkText, watermarkOption);
}
System.out.println(bundle.getString("TEXT13"));
mergedPDF.getPages().add(existingPDF.getPages());
} catch (Exception e) {
System.out.println(e.getCause() + "-->" + e.getMessage());
}
}
}
System.out.println(bundle.getString("TEXT14"));
mergedPDF.save(outputFile);
mergedPDF.close();
mergedPDF.dispose();
if (pageNumbers.equalsIgnoreCase("X")) {
AddPageNumbers addPages = new AddPageNumbers();
addPages.addPages(outputFile, gv_lan, gv_cntry);
}
// System.out.println("Merging complete!");
System.out.println(bundle.getString("TEXT15"));
}
}}