Completed
Last Updated: 31 Jan 2024 11:39 by ADMIN
Release 2024 Q1 (2024.1.130)
Nadya
Created on: 01 Dec 2023 12:19
Category: PdfViewer
Type: Bug Report
1
RadPdfViewer: A password is asked although adobe opens the document without one
A password is asked although adobe opens the document without one
1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 01 Dec 2023 12:26

Hello,

You can use the following workaround:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        PdfImportSettings pdfImportSettings = new PdfImportSettings();
        this.radPdfViewer1.PdfViewerElement.ImportSettings = pdfImportSettings;
        pdfImportSettings.OwnerPasswordNeeded += ImportSettings_OwnerPasswordNeeded;
    }

    private void ImportSettings_OwnerPasswordNeeded(object? sender, Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PasswordNeededEventArgs e)
    {
        var password = (this.radPdfViewer1.PdfViewerElement as CustomPdfViewerElement).Call_ShowPasswordRequireDialog();
        e.Password = password;
    }

    private void bWithPermissionPasswordOnly_Click(object sender, EventArgs e)
    {
        radPdfViewer1.LoadDocument(@"resources\WithPermissionPasswordOnly.pdf");
    }

    private void bWithDocumentOpenPassword_Click(object sender, EventArgs e)
    {
        radPdfViewer1.LoadDocument(@"resources\WithDocumentOpenPassword.pdf");
    }
}
public class CustomPdfViewer : RadPdfViewer
{
    protected override RadPdfViewerElement CreateViewerElement()
    {
        return new CustomPdfViewerElement();
    }
}
public class CustomPdfViewerElement : RadPdfViewerElement
{
    public string Call_ShowPasswordRequireDialog()
    {
        return ShowPasswordRequireDialog();
    }
}

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.