• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Protect PDF using ProtectPDF API

New Here ,
Sep 13, 2021 Sep 13, 2021

Copy link to clipboard

Copied

Hi Team, 

I am getting the below exception when trying to use ProtectPDF API.

com.adobe.pdfservices.operation.exception.ServiceApiException: description ='Source file is protected and cannot be processed.; transactionId=JdVKSQv70gO5uhbG6uzMPQyWTAzFpRRp';

 

Kindly let me know in case any suggestions 

Views

979

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Is the message true? Is the file encrypted and what security options are set? (Not sure? Use Acrobat/Reader, File > Properties; Security tab).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Yes the message is true as i am receiveing in the response.I have tried to open the file (Acrobat/Reader, File > Properties; Security tab) and there i could able to see the Security Method:Password Security. When i was trying to open that pdf file its not promting to give any password. So how to convert these kind of files using Adobe Protect API any suggestions please.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Security can't be applied to files that are already secured. If you are trying to change the password and know it, then you can use the Remove Protection service to remove the existing security and then apply a new password.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Thanks Joel a lot. I have tried to open the file (Acrobat/Reader, File > Properties; Security tab) and there i could able to see the Security Method:Password Security. When i was trying to open that pdf file its not promting to give any password. So how to convert thses kind of files using Adobe Protect API.As suggested by you i have tried to use the Remove Protection as i dont know the password its throwing the same exception.(The password is not autorized to remove the security) 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

There are two kinds of password security for PDF. An owner password which you would need to know in order to open the file, and a permissions password, which limits what you can do with the file once opend. If only a permissions password is set, you will not be prompted to enter a password when the document is opened but "Password Security" is still shown as the security method because you'd need to know the permissions password to override the restrictions.

Unless you know the password and remove the encryption, you will not be able to use the Protect API on that file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Thanks Joel for your complete analysis . Basically my requirement is to convert the pdf file to pdf file . But here in this case the pdf file is having one button "Clear" button and cliking on that button will clear the form data , but my requirement is to presesve the form data even if after the converion of file.  So in this scenario initailly i have tried to use " Create PDF API" but it wont help me to preseve the form data after conversion of file.So i have tried for "Protect PDF API" but this is not working in this scenario. So can you please suggest how to achieve this using Document Service API. I have tried to implement the same without using Document Service API by using below codes.

 

PDAcroForm pDAcroForm = pDDocument.getDocumentCatalog().getAcroForm();
//Flatten the document
pDAcroForm.flatten();

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

You can't fix protected forms. You need to get the password from the form's creator, remove the password, and then you can edit.

 

The sole purpose of the acroform.flatten function is to remove form data, so you should not be using it if your aim is to have form fields ! What are you actually trying to achieve?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Thanks a lot for your response. Currently i am able to acheieve this using the below piece of codes. Even after i am able retain the form data after conversion of pdf to pdf. In this scenario clicking on the button "Reset Form data" it's not removing the form data.

PDAcroForm pDAcroForm = pDDocument.getDocumentCatalog().getAcroForm();
if(pDAcroForm !=null){
pDAcroForm.flatten();
}

But by using Document Service API(Adobe API) if we can achieve the same kindly let me know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Ok - After looking through my Teams thread with your rep, now I know who you are. My understanding is that you have some filled out forms and need to make them non-interactive while still retaining the form data. If that is correct, you will not be able to use PDF Services API to accomplish your goal without knowing the password for the file. In fact, you won't be able to use any API without the password.

What you'd need to do is remove the permissions password that allows for form filling and signing and replace it with a permissions password that prevents any editing at all.

My strong recommendation is to contact the originator of the form to get the password or rethink your solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Is the code you provided for PDFBox? It looks like it to me. There might be a very simple solution for you if that's true.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

Thanks Joel for your nice explanation, So that means there is no way to retain the file data which is having Security Method as "Password Security" using document service API.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2021 Sep 14, 2021

Copy link to clipboard

Copied

LATEST

Correct. But, if that's PDFBox that you are using to flatten, you can just as easily set the field properties to read-only and leave the security settings as is so you won't need to flatten. You wouldn't need the password that way.

Since we don't have an Adobe solution for you, I don't mind recommending that method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources