Metadata gets cleared after encryption

Hi all,

I have observed that all document metadata gets cleared after encrypting the document. This includes custom properties. Is this the expected behavior? Is there a way to preserve custom properties?

My code fragment:

PdfFileInfo info = new PdfFileInfo("input.pdf");
...
info.saveNewInfo("temp.pdf");
...
PdfFileSecurity fileSecurity = new PdfFileSecurity("temp.pdf", "output.pdf");
fileSecurity.encryptFile(null, "mypassword", permission, true);

Thanks!

Hi Jennefer,

I have tried to reproduce this issue at my end and couldn't do so. Can you please share the complete code snippet and the PDF you're working with so I could reproduce the problem at my end and resolve the issue?

We're sorry for the inconvenience.

Regards,

Hi shahzad,

Thanks for the quick response.

Find below the complete code. Also attached are the resulting PDF files. The program first saves the metadata into an intermediate pdf file (abc50186.pdf), and finally, encryption is applied (example1-out.pdf). Note that abc50186.pdf contains the meta info but got cleared in example1-out.pdf.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import com.aspose.pdf.kit.License;
import com.aspose.pdf.kit.PdfFileInfo;
import com.aspose.pdf.kit.PdfFileSecurity;
import com.aspose.pdf.kit.PdfPrivilege;

public
class MetaInfoTest {

public static void main(String[] args) {
try {
setLicense();
String inputFile = "C:\\data\\workspace\\Aspose\\example1.pdf";
String outputFile = "C:\\data\\workspace\\Aspose\\example1-out.pdf";
PdfFileInfo info = new PdfFileInfo(inputFile);
File tempFile = File.createTempFile("abc", ".pdf", new File("C:\\data\\workspace\\Aspose"));
OutputStream ostemp = null;
boolean ok = false;
try {
ostemp = new FileOutputStream(tempFile);
info.setMetaInfo("metainfo1", "123");
info.setMetaInfo("metainfo2", "456");
ok = info.saveNewInfo(ostemp);
} finally {
ostemp.close();
}
if(ok) {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(tempFile);
os = new FileOutputStream(outputFile);
PdfFileSecurity fileSecurity = new PdfFileSecurity(is, os);
fileSecurity.encryptFile(null, "mypassword", PdfPrivilege.ScreenReaders, true);
} finally {
is.close();
os.close();
}
}
} catch(Exception e) {
e.printStackTrace();
}
System.exit(0);
}

private static void setLicense() throws Exception {
License license = new License();
String licFile = "C:\\data\\workspace\\Aspose\\Aspose.Pdf.Kit.license";
FileInputStream stream = new FileInputStream(licFile);
license.setLicense(stream);
}
}

If the following info helps:
I am using Acrobat 7.0 Standard to open the PDF files
I am using the latest Pdf Kit 2.3.0.0

Thanks!

Hi,

Thanks for reporting this,

We have tested the scenario and are able to reproduce the problem. And it has been logged as PDFKITJAVA-9287 in our issue tracking system. We will try to resolve it ASAP.

Thanks,

Hi all,

Any update for this issue? It’s been more than a month, is there any fix soon?

Thanks,
Jaq

Hi Jennefer,

I’m afraid to inform you that this issue is not yet resolved. I’m sorry to add that we can’t share the ETA at the moment. Our team will be looking into the matter and you’ll be updated accordingly.

We appreciate your patience.
Regards,



Hi team,

Any ETA for this issue yet? We have implemented a dependent module into production hoping this could be given attention very soon.

Thanks,
Jaq

Hi Jennefer,

This issue is resolved and will be included in our September 2009 release. We’ll publish the release in the next week.

Regards,

The issues you have found earlier (filed as 9287) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi team,

Thanks for the fix. We really appreciate it.