A simple way to remove the security from a PDF?

Q: Is there an easy way to remove the security settings from a pdf.
The way that we are doing it right is we make a new pdf with no
security attributed to it and append the pages of the secure pdf to
it. Essentially dismantling and re-assembling the document to remove
the security settings (password etc…). What isn’t good about this is
that it strips out the bookmarks as well as inflating the file size of
the original pdf by over double.
-------
A: The simplest way to remove the security from a PDF is to call
pdfdoc.RemoveSecurity() than save the document using pdfdoc.Save(...).
This approach will also preserve all bookmarks, metadata, etc.

Q: Ok that removed the requirement of me to enter a password but it
looks like the pdf is still encrypted. I'm getting an error when I
try to open the pdf that I just removed the security from.
------
A: Did you initialize the security handler using
doc.InitSecurityHandler()? For example,

...
PDFDoc doc = new PDFDoc("my.pdf");
if (!doc.InitSecurityHandler()) { // Need password to open the
document
  doc.InitSecurityHandler();
}

doc.RemoveSecurity();
doc.Save(…);
doc.Dispose();
...

I assumed that you meant:

if(!doc.InitSecurityHandler())
{
  doc.InitStdSecurityHandler(password);
}

And, YES it did work. That is a much better way than the way we were
doing it before thanks.