Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Sat Aug 13, 2016 4:25 pm

Using latest eval version of commercial PDFViewer, I change a field to readonly, set the security on a PDF, and saved it to disk.


<snip>

// we are looping through widget.FieldsWidget.List.Count

PdfField f = widget.FieldsWidget.List[i] as PdfField;

if (f.Name == "test")
{
PdfTextBoxFieldWidget tf = f as PdfTextBoxFieldWidget;
tf.Text = "X3G-T";
f.Flatten = true;
f.ReadOnly = true;
break;
}
<snip>


pdf.Security.OwnerPassword = ownerPassword;
pdf.Security.UserPassword = "spire#";
pdf.Security.Permissions = PdfPermissionsFlags.AccessibilityCopyContent | PdfPermissionsFlags.CopyContent | PdfPermissionsFlags.FillFields | PdfPermissionsFlags.FullQualityPrint | PdfPermissionsFlags.Print;
pdf.Security.KeySize = PdfEncryptionKeySize.Key256Bit;

using (FileStream fs = new FileStream(@"c:\encrypted3.PDF", FileMode.CreateNew))
{
pdf.SaveToStream(fs, FileFormat.PDF);
}
pdf.Close();
}


When I open this PDF in Acrobat, it behaves properly, asking for the user password, and with the correct permissions.

However, when I later attempt to open it in Spire, supplying the ownerPassword (the permissions password)

// pdf.Security.KeySize = PdfEncryptionKeySize.Key256Bit; // tried both ways, with/without this line
pdf.LoadFromFile(dialog.FileName, ownerPassword);

there is an exception in Spire.Pdf.dll :

Source array was not long enough. Check srcIndex and length, and the array's lower bounds.

tr888
 
Posts: 7
Joined: Fri Aug 12, 2016 3:53 pm

Mon Aug 15, 2016 4:45 am

Dear tr888,

Thanks for your feedback.
I have tested your scenario but sorry that I didn't reproduce your issue. Could you please provide us the documents( original document and the result document after setting the security ) so that we can work out it ASAP ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Mon Aug 15, 2016 11:49 am

I will have to put together a sample later this morning. Unfortunately, the PDF I was working with had some real information in it which I cannot send out :)

tr888
 
Posts: 7
Joined: Fri Aug 12, 2016 3:53 pm

Tue Aug 16, 2016 7:51 am

Dear tr888,

Thanks for your reply.
You can send the sample file to us( Support@e-iceblue.com) via eamil.
Also, you can change or remove the real information as long as the document can reproduce your issue, and then send it to us for investigation. We promise to keep it confidential and won’t use it for any other purpose.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Wed Aug 17, 2016 6:50 pm

I downloaded Spire.Office and the Hotfix, and am still getting this error.

The PDF was created and encrypted using Adobe Acrobat Pro version XI.

May I ask, what level of AES-256 bit encryption does Spire support? I believe Adobe Acrobat Pro XI has jumped ahead from R5 to R6.

Is Spire able to open a PDF which has been encrypted with an ownerPassword in Adobe Acrobat Pro version XI? Can you please confirm that?

When I attempt to open this same PDF using iTextSharp, I get an exception message that the "Encryption type is unknown R=6".

tr888
 
Posts: 7
Joined: Fri Aug 12, 2016 3:53 pm

Thu Aug 18, 2016 2:29 am

Dear tr888,

Thanks for your feedback.
Spire.PDF can open the file which is encrypted with an ownerPassword, could you please provide sample document and the password so that we can investigate it ?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.PDFViewer

cron