问题
I am using iTextSharp to manipulate PDF documents. I have to make PDF document encrypted and I am able to do it. The only problem that I am getting now is the format of form fields - they got changed.
For example:
I have text field of 'Integer' type with format '1,234.00'. Before encrypting the format is what I have set. But after encrypting the PDF the format changes to default i.e. value becomes '1234'.
Any suggestion?
UPDATE:
I am using following code to set password on document:
PdfReader reader = new PdfReader(document, System.Text.Encoding.UTF8.GetBytes("pass"));
using (MemoryStream ms = new MemoryStream())
{
using (PdfStamper stamper = new PdfStamper(reader, ms))
{
}
using (FileStream fs = new FileStream(
tempFile, FileMode.Create, FileAccess.ReadWrite))
{
PdfEncryptor.Encrypt(
new PdfReader(ms.ToArray()),
fs,
PdfWriter.DO_NOT_ENCRYPT_METADATA,
null,
"pass",
PdfWriter.ALLOW_PRINTING
| PdfWriter.ALLOW_COPY
);
}
}
reader.Close();
来源:https://stackoverflow.com/questions/19274129/pdf-field-format-changes-after-encrypting-the-pdf-document-using-itextsharp