sushmakanugu | Posts: 48

Document Locked

0 votes
While trying to add the document of one package to other package, am getting an exception : Bad Request(400), message:"Cannot upload the document. Please make sure it is not locked." How can I unlock the document and add it to other package?

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
Hey, The error message you are getting is an expected behavior. Once a package has been completed, the signed documents are sealed and cannot be tampered or otherwise. The reason behind this is to protect the signer from possibly illegal transactions. Any change in the signed document metadata will result in a corrupt PDF and all the signatures will be lost.

sushmakanugu | Posts: 48

Reply to: Document Locked

0 votes
Actually, I was trying to add those documents which are unsigned in one package to other package. For some details like FileName which is mandatory for uploading the document to package, I have build the document using DocumentBuilder and tried to upload, but am getting the exception. Is there a way to add unsigned documents of one package to other package?

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
In this case, I will need more information from you. Can you please provide me the following:
  1. the package id of the documents you are trying to add to another package
  2. the actual documents you are trying to upload
  3. a snippet of your code where you are building your document object

sushmakanugu | Posts: 48

Reply to: Document Locked

0 votes
1. Package id : NM1CvmaO1Spdxc0mXcZTvF0ftmI= 2. Document id trying to upload is: c30761b0-e9e4-4eb2-9fb9-846cc6249b0b 3. Code: var newPackageId = //creating new package var unsignedSilanisDocuments = //Retrieving unsigned packages from existing package given above foreach (var doc in unsignedDocuments) { doc.Content = _eslClient.DownloadOriginalDocument(new PackageId(oldPackageId), documentId); var document = DocumentBuilder.NewDocumentNamed(doc.Name) .WithId(doc.Id) .FromStream(new MemoryStream(doc.Content), DocumentType.PDF); var newDoc = document.Build(); doc.FileName = newDoc.FileName; } //Within other loop Adding unsinedSilanisDocuments to new Package _eslClient.UploadDocument(unsignedSilanisDocument, newPackageId);

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
I ran a few tests on my side and it seems that once a package has been sent, the documents become secure and can't be modified (regardless if there are unsigned signatures or no signatures at all on the documents). You will either have to use a PDF unlocker or use the original documents that was used to create your package (e.g. NM1CvmaO1Spdxc0mXcZTvF0ftmI=)

sushmakanugu | Posts: 48

Reply to: Document Locked

0 votes
Could you please elaborate PDF unlocker? Is this a general PDF unlocking or does silanis provide any method to unlock? I have tried unlocking using pdfsharp library, but am not successful(the encryption used is not available in pdfsharp library). Could you provide a way to unlock the document?

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
Hey, Sorry i wasn't referring to any pdf unlocker in particular. Unfortunately, eSignLive doesn't provide any unlocking methods for pdf as it would go against policy. You will have to do this on your end. Doing a quick google search, I was able to find this: http://www.codeproject.com/Articles/31493/PDF-Security-Remover Using the pdfsharp library, the author was able to read in the secured original PDF then copy each page to a new PDF file and save it.

sushmakanugu | Posts: 48

Reply to: Document Locked

0 votes
Hi, I tried all possible ways to get it unlocked, but i could see an exception "The PDF document is protected with an encryption not supported by PDFsharp".

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
Is there a specific reason for pulling your documents from a package instead of simply getting them from your system? If you have to use the documents from the esignlive package for any reason, you could unlock it with a tool like iTextSharp:
using System;
using System.Diagnostics;
using Silanis.ESL.SDK;
using Silanis.ESL.SDK.Builder;
using System.IO;
using iTextSharp.text.pdf.parser;
using iTextSharp.text.pdf;

class iText
{
     class MyReader : PdfReader {
        public MyReader(String filename) : base(filename) {
            ;
        }
        public void decrypt() {
            encrypted = false;
        }
    }

    public static String SRC = @"\...\locked.pdf";
    public static String DEST = @"\...\unlocked.pdf";

    public static void Main(string[] args)
    {
        new iText().manipulatePdf(SRC, DEST);
    }

    public void manipulatePdf(String src, String dest) {
        MyReader.unethicalreading = true;
        MyReader reader = new MyReader(src);
        reader.decrypt();
        PdfStamper stamper = new PdfStamper(reader, File.Create(dest));
        stamper.Close();
        reader.Close();
    }
}
However, remember that if any document you pull already has signatures on it, unlocking it will invalidate the signatures.

sushmakanugu | Posts: 48

Reply to: Document Locked

0 votes
Thank you Haris. This is working.

harishaidary | Posts: 1812

Reply to: Document Locked

0 votes
Glad to hear it :)

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off