You are viewing limited content. For full access, please sign in.

Question

Question

Identify password protected pdfs

asked on August 26, 2016

Is there anyway to search for password protected PDFs in Laserfiche? Can the SDK do this? 

 

We have a client that has some unknown number of password protected PDFs that are sent to DCC and cause it to run for hours since it cant extract text from them. 

0 0

Answer

SELECTED ANSWER
replied on August 29, 2016

Like the other posts imply, it sounds like something else is going wrong. Is DCC actually processing files during the long time period or are you just waiting indefinitely for images to get OCRed?

For anyone who is curious, here is how you would find password protected PDFs using the sdk. Download the electronic file and use iTextSharp to open it. Not shown is the code to run a search for {LF:Name="*", Type="D"} that finds all documents in the repository.

bool isPasswordProtected(DocumentInfo doc)
{
    string contentType;
    using (MemoryStream pdfStream = new MemoryStream())
    using (LaserficheReadStream edocStream = doc.ReadEdoc(out contentType))
    {
        edocStream.CopyTo(pdfStream);
        pdfStream.Seek(0, SeekOrigin.Begin);

        try
        {
            PdfReader reader = new PdfReader(pdfStream);
            return false;
        }
        catch (BadPasswordException)
        {
            return true;
        }
    }
}

 

1 0

Replies

replied on August 26, 2016

DCC only OCRs images, it does not open any PDF files.

1 0
replied on November 27, 2023

It does now, and seems to fall over/stall when it comes across a password protected PDF. Currently trying to find a way to deal with this.

0 0
replied on August 26, 2016

The Laserfiche server doesn't inspect PDFs to see if they are password-protected.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.