Process works once but then Document appears to be corrupted and cannot be loaded

Document conversion and viewing problem.docx (24.7 KB)

The attached document outlines a problem I have been dealing with for some days. It is difficult to explain so I thought a document with a picture might help.

Please help

@john.gleeson If possible, could you please create a simple application that will allow us to reproduce the problem on our side? Do you open the source document by Aspose.Words from stream? Is it possible the same stream is used again while opening the document the second time? If so, please make sure the stream position is at the beginning. This might be the reason of the problem on your side.

No we open the file directly using this code

Sub SaveDocAsPDF(strSourceDocFilePath As String, strTargetDocFilePath As String, Optional PDFPermission As Saving.PdfPermissions = Saving.PdfPermissions.DisallowAll)
    Try
        Dim docOutput As New Document(strSourceDocFilePath)
        Dim pdfSaveOptions As New Aspose.Words.Saving.PdfSaveOptions
        Dim encryptDetails As New Aspose.Words.Saving.PdfEncryptionDetails("", "owner")
        Dim docSaveOptions As New Aspose.Words.Saving.DocSaveOptions
        encryptDetails.Permissions = PDFPermission ' if required we could set the permissions to allow printing
        pdfSaveOptions.EncryptionDetails = encryptDetails
        docOutput.Save(strTargetDocFilePath, pdfSaveOptions)
    Catch ex As Exception
        Dim o As New VT_DataAccess.LoggingUtilFunctions
        o.LogAction("error in SavedocAsPDF: " + ex.Message)
    Finally
    End Try
End Sub

~WRD0002.jpg (357 Bytes)

@john.gleeson Unfortunately, it is difficult to say what causes the problem. Could you please create a simple application that will allow us to reproduce the problem on our side? We will check your scenario on our side and provide you more information.

Hi

Producing a simple app would be very difficult and I have found in the past that doing that often results in not seeing the problem at all because the same set of options is not in place.

Would it be possible to arrange a call via Teams or similar where I could show you the setup in Visual Studio?

john

~WRD0002.jpg (357 Bytes)

@john.gleeson Unfortunately, we do not provide support via phone or video calls. The main place for getting support is this forum.