We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to disable print button in pdf


We are trying disable print button in the PDF, but unable to do so as the generated PDF still has print option.
Kindly help.
Attached following files for reference.
1. Input PDF - Test.pdf
2. Generated PDF - Test_NoPrint.pdf (Password : owner)
3. Code - NoPrintPDF.txt
4. Jar used - aspose.pdf-10.6.2.jar
5. Java version used - jdk1.6.0_35

Hi Prabu,

Thanks for using our API.

Aspose.Pdf for Java offers the feature to create as well as manipulate existing PDF files and it can only perform manipulation at file level. However the print button is appearing on PDF viewing application and our API cannot have control to disable/hide that button.

As per your requirement, you can disable PDF printing by setting privileges over PDF file. Please try using documentPrivilege.setAllowPrint(false);

For your reference, I have also attached the PDF file generated over my end. When viewing the file in Adobe Reader and opening the file with User password, you will notice that printing is restricted.

Hi, Thanks for your reply.

I tried using documentPrivilege.setAllowPrint(false) but still i could not disable the PDF.
I am using Adobe Reader 9.5 to open the PDF and verify, is anything to do with the Adobe Reader?
Have attached the screenshot of the Adobe reader security for generated file.
I cannot open the file attached in your reply, can you pls attach again?

Hi Prabu,

Please take a look over attached image file which shows security settings over PDF document. For your reference, I have again attached the PDF file with security privileges. Please note that in order to view the PDF file, you need to use user and owner passwords.

PS, the attached image is taken when viewing the file with user password.

Hi, Thanks it working when i open the document with password ‘user’. Previously i was trying with password owner. Thanks for helping.

I have another problem while converting the XPS file to PDF.
I am getting below error during conversion.

Exception in thread “main” class com.aspose.pdf.internal.ms.System.z9: At most 4 text fragments can be added in evaluation mode.
com.aspose.pdf.TextBuilder.m1(Unknown Source)
com.aspose.pdf.TextBuilder.appendText(Unknown Source)
com.aspose.pdf.z6.m1(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z16.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z13.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z10.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z13.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z29.accept(Unknown Source)
com.aspose.pdf.z6.m1(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.z236.m1(Unknown Source)
com.aspose.pdf.ADocument.m1(Unknown Source)
com.aspose.pdf.ADocument.(Unknown Source)
com.aspose.pdf.Document.(Unknown Source)
at com.aspose.pdf.TextBuilder.m1(Unknown Source)
at com.aspose.pdf.TextBuilder.appendText(Unknown Source)
at com.aspose.pdf.z6.m1(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z16.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z13.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z10.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z13.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z29.accept(Unknown Source)
at com.aspose.pdf.z6.m1(Unknown Source)
at com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
at com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
at com.aspose.pdf.z236.m1(Unknown Source)
at com.aspose.pdf.ADocument.m1(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at AsposeXpsToPDF.main(AsposeXpsToPDF.java:17)

Have attached following docs for your reference, pls not i am using 30 days evaluation licence.
1. Code - XpsToPdf.txt
2. Source File - XpsToPdf.xps

Please assist.

Hi Prabu,

Thanks for your inquiry. I have tested the scenario using your sample code and source XPS document but unable to notice the reported issue. We will appreciate it if you please double check license file availability and its subscription expiry date. Hopefully it will help you to accomplish the task. If the issue persist then please share your license file here. We will look into it and guide you.

We are sorry for the inconvenience caused.

Best Regards,

Hi, As per your advice, i tried again but unfortunately ended up with same error. Attached License file for your reference.

Hi Prabu,

Thanks for your feedback and sharing license file. I am afraid I am still unable to replicate the issue. I am using Aspsoe.Pdf for Java 10.6.0 and Eclipse with JDK 1.7 on Win 7 64 bit. Please share your environment details, so we will try to replicate the issue and provide you information accordingly.

We are sorry for the inconvenience caused.

Best Regards,