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

Free Support Forum - aspose.com

How to protect an existing pdf

hi,
I have downloaded Aspose.Pdf Library and I'd like to know how I can use it to protect (making readonly) an existing pdf file.
I tried with Aspose.Pdf.Generator.Pdf() object and Security property with the code VB below:

Dim invoiceobject As Aspose.Pdf.Generator.Pdf
Dim secur As Aspose.Pdf.Generator.Security
Dim oFileStream As System.IO.FileStream

oFileStream = MyLibrary.GetInvoice()

invoiceobject = New Aspose.Pdf.Generator.Pdf(oFileStream)

secur = New Aspose.Pdf.Generator.Security()
secur.IsPrintingAllowed = True
secur.IsContentsModifyingAllowed = False

invoiceobject .Security = secur
invoiceobject .Save("d:\ReadOnlyInvoice.pdf")
invoiceobject .Close()

The code runs correctly (there is no exception) but invoiceobject doesn't create the "ReadOnlyInvoice.pdf". Can anybody help me please?
Thank you
Simone

Hi Simone,


Thanks for using our products.

Aspose.Pdf.Generator supports the feature to create PDF document from scratch and it offers the capability to apply security restrictions while creating PDF document. However if you need to apply restrictions on existing PDF file, then please follow the instructions specified over Set Privileges on an Existing PDF File (Facades)

In case you still encounter similar issue or you have any further query, please feel free to contact.