Free Support Forum - aspose.cloud

VB Net API to Cloud - Password Protect PDF

I have the following code which creates a PDF file from a DOCX,

I want to add a password to the PDF - how do I achieve this?

public void WordFile(string Filename, string ConvertFormat)
{

 Aspose.Cloud.Words.Converter converter = new Aspose.Cloud.Words.Converter();

 Aspose.Cloud.Words.SaveFormat format;

 wordsFormats.TryGetValue(ConvertFormat, out format);

 converter.ConvertLocalFile(fileName, outputName, format);

}

@neilcooley79

Please use SaveAs API with Conversion Settings. Please check documentation for more details and use latest version of Aspose.Words Cloud SDK for .NET.

Private Shared Sub SaveAsWordtoPDF()
    Dim localFolder As String = "C:/Temp/"
    Dim remoteFolder As String = "Temp"
    Dim localName As String = "02_pages.docx"
    Dim remoteName As String = "TestSaveAsFromDocToPdf.docx"
    Dim uploadRequest As Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest = New Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder & localName), remoteFolder & "/" & remoteName)
    wordsApi.UploadFile(uploadRequest)
    Dim pdfSecurity = New PdfEncryptionDetailsData() With {
        .UserPassword = "userpassword",
        .OwnerPassword = "ownerpassword"
    }
    Dim request = New SaveAsRequest(name:=remoteName, saveOptionsData:=New PdfSaveOptionsData() With {
        .SaveFormat = "pdf",
        .FileName = "TestSaveAsFromDoctoPdf.pdf",
        .EncryptionDetails = pdfSecurity
    }, folder:=remoteFolder)
    Dim actual = wordsApi.SaveAs(request)
End Sub