Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8576211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:52:35+00:00 2026-06-11T19:52:35+00:00

I m creating and signing pdf using c#,itextsharp.Now i m using this code for

  • 0

I m creating and signing pdf using c#,itextsharp.Now i m using this code for password protection and digital sign.First i am protecting with password.Than i am signing.

the transmitted pdf is not asking password while opening?
Can someone tellme why is this happening?

Thanks..

string passprotectedfile = filename;

using (Stream input = new FileStream(signedfile, FileMode.Open, FileAccess.Read,
                                     FileShare.Read))
{
    using (Stream output = new FileStream(passprotectedfile, FileMode.Create, 
                                          FileAccess.Write, FileShare.None))
    {
        PdfReader reader = new PdfReader(input);
        PdfEncryptor.Encrypt(reader, output, true, regno.ToString(), "",
                             PdfWriter.ALLOW_SCREENREADERS);
    }
}

Code i am using for digitally sign.

        PdfReader reader = new PdfReader(filename,pass);
        Stream output = new FileStream(signedfile, FileMode.Create, FileAccess.Write, FileShare.None);
        PdfStamper stamper = PdfStamper.CreateSignature(reader, output, '\0');

        Rectangle rect = new Rectangle(455, 105, 555, 170);
        PdfSignatureAppearance appearance = stamper.SignatureAppearance;
        appearance.SetVisibleSignature(rect, 1, "sign");
        PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("adobe.pkcs7.detached"));
        PrivateKeySignature pks = new PrivateKeySignature(pk, "SHA-256");
        MakeSignature.SignDetached(appearance, pks, chain, null, null, null, 0, true);
        return filename;

then i am transmitting.

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=tes2.pdf");
            Response.TransmitFile(signedfile);
            Response.Flush();

            File.Delete(signedfile);
            File.Delete(newfile);
            File.Delete(passprotectedfile);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:52:36+00:00Added an answer on June 11, 2026 at 7:52 pm

    You’re creating a PdfReader instance using an owner password that allows iText to decrypt the password protected PDF. That explains why the password protection is gone: you told iText to decrypt the file.

    If you want a file that is signed as well as encrypted, you need to do both operations in one go, not sequentially! The PdfStamper class has different methods that allow you to set the encryption. Use one of these methods on the stamper object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m creating and signing pdf using c#,itextsharp.Now i m using this code for
I am using ASP.NET, C# and iTextSharp 5.3.0 for creating and digitally signing a
Creating a simple RPG game, first time using XNA. Trying to get my character
I'm trying to sign an ActiveX control with a code signing certificate issued by
I am considering purchasing a code signing certificate from VeriSign or Thawte to sign
This is an extension question to: how-do-i-create-a-self-signed-certificate-for-code-signing-on-windows To take this further, if I have
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
How do I sign an APK with more than one certificate, so that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.