Example #1
0
 public List<PdfDocumentDescriptor> load(List<PdfDocumentDescriptor> toLoad) {
   LOG.debug(DefaultI18nContext.getInstance().i18n("Loading documents"));
   List<PdfDocumentDescriptor> loaded = new ArrayList<>(toLoad.size());
   for (PdfDocumentDescriptor current : toLoad) {
     PdfDocumentDescriptor copy = newCopy(current);
     PdfReader reader = null;
     try {
       reader = current.toPdfSource().open(PdfSourceOpeners.newPartialReadOpener());
       copy.setEncryptionStatus(EncryptionStatus.NOT_ENCRYPTED);
       copy.setPages(reader.getNumberOfPages());
       copy.setVersion(String.format("1.%c", reader.getPdfVersion()));
       @SuppressWarnings("unchecked")
       Map<String, String> meta = reader.getInfo();
       for (PdfMetadataKey key : PdfMetadataKey.values()) {
         copy.addMedatada(key, defaultString(meta.get(key.getKey())));
       }
       loaded.add(copy);
     } catch (TaskWrongPasswordException twpe) {
       copy.setEncryptionStatus(EncryptionStatus.ENCRYPTED);
       loaded.add(copy);
       LOG.warn(String.format("Owner password required %s", current.getFileName()), twpe);
     } catch (Exception e) {
       LOG.error(
           String.format("An error occured loading the document %s", current.getFileName()), e);
     } finally {
       nullSafeClosePdfReader(reader);
     }
   }
   LOG.debug(DefaultI18nContext.getInstance().i18n("Documents loaded"));
   return loaded;
 }
Example #2
0
 @Override
 public void before(EncryptParameters parameters) {
   totalSteps = parameters.getSourceList().size();
   sourceOpener = PdfSourceOpeners.newPartialReadOpener();
   outputWriter = OutputWriters.newMultipleOutputWriter(parameters.isOverwrite());
   for (PdfAccessPermission permission : parameters.getPermissions()) {
     permissions |= getAccessPermission(permission);
   }
 }
Example #3
0
 @Override
 public void before(DecryptParameters parameters) {
   totalSteps = parameters.getSourceList().size();
   sourceOpener = PdfSourceOpeners.newPartialReadOpener();
   outputWriter = OutputWriters.newMultipleOutputWriter(parameters.isOverwrite());
 }