异常:The encryption revision value must be 6 for encryption version 5.
Closed this issue · 9 comments
We recently added support for loading old files of deprecated revision 5 created with other tools, which use encryption version 5, too. It will be available with the final version of PDFsharp 6.2.0.
Hi,
I have the same problem. I use pdfsharp 6.1.1 on RestApi:
using (MemoryStream ms = new MemoryStream(currentFile.Content))
{
using (var pdfDoc = PdfReader.Open(ms, PdfDocumentOpenMode.Import))
{
for (var i = 0; i < pdfDoc.PageCount; i++)
pdfOutDocument.AddPage(pdfDoc.Pages[i]);
}
}
The Error comes in PdfReader.Open(ms, PdfDocumentOpenMode.Import))
The encryption revision value must be 6 for encryption version 5.
at PdfSharp.Pdf.Security.Encryption.PdfEncryptionV5.CheckValues(Nullable1 versionValue, Nullable
1 revisionValue, Nullable`1 lengthValue)
at PdfSharp.Pdf.Security.Encryption.PdfEncryptionV5.ValidatePassword(String inputPassword)
at PdfSharp.Pdf.Security.PdfStandardSecurityHandler.ValidatePassword(String inputPassword)
at PdfSharp.Pdf.IO.PdfReader.OpenFromStream(Stream stream, String password, PdfDocumentOpenMode openMode, PdfPasswordProvider passwordProvider, PdfReaderOptions options)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openMode, PdfPasswordProvider passwordProvider, PdfReaderOptions options)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openMode, PdfReaderOptions options)
Can you help me here?
Can you help me here?
Can you help me to extract the PDF files from your attachment?
The content.txt is in json format.
The shema is:
[
{
"FileName": "string",
"Content": "string" // this is a BASE64
}
]
Was that your question?
You can use this class (c#):
public class PdfFileUpload
{
public string? FileName { get; set; }
public byte[]? Content { get; set; }
}
and parse the json in a generic list of PdfFileUpload-Type
It works fine with this example:
successful.txt
and parse the json in a generic list of PdfFileUpload-Type
If you would simply attach a ZIP with the 2 PDFs, then I could access the PDFs without writing code.
You can use this template to submit PDF files and code:
https://docs.pdfsharp.net/General/Issue-Reporting.html
I have add it as zip, but I'm not sure if that's the problem. I use it in an asp.core project and the files are uploaded as base64.
Thank you!
Thanks for the feedback and the files.
The second file of the zip is encrypted with version 5 revision 5. This is a deprecated encryption method which shall not be used anymore. Of course, there may be files that were encrypted with this method and even applications being used still using this method. Due to this, we recently added support for reading it, but this change is not published yet. With the next release of PDFsharp, you will be able to load this file. As we are currently working on the 6.2.0 version, I hope it will be available soon.
Hi martinossendorf,
thank you very much for your commitment and the fix. I will wait for the next version.
kind regards
Petar