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

Free Support Forum - aspose.com

Problem in append file (.jpg, .png, .doc) in to pdf

//Here is my code and I face issue of Object reference null in below given statement

string dataDir = Server.MapPath("~/Doc");
        Document pdfDocument = new Document(dataDir + "//test.pdf");
        // Setup new file to be added as attachment
        FileSpecification fileSpecification = new FileSpecification(dataDir + "//Aetna.txt", "Sample text file");
        // Specify Encoding proparty setting it to FileEncoding.None
        fileSpecification.Encoding = FileEncoding.None;
        // Add attachment to document's attachment collection
        dataDir = dataDir + "DisableFilesCompression_out.pdf";
        // Save new output


Thank you for contacting support.

We have worked with the code snippet shared by you but the exception has not been reproduced with Aspose.PDF for .NET 18.9.1. Please ensure using latest version in your environment. In case the issue persists then please share your source files with us so that we may investigate further to help you out.