Free Support Forum - aspose.com

NullReferenceException when converting pdf to pdf\a on Mono

Using the code below with latest Mono, under CentOS 7, gives NullReferenceException, while it works fine on Windows under .NET 4.5. Code tries to convert regular pdf to PDF\A format. This code assumes Aspose.Total.lic and example.pdf (attached, but it fails with any pdf I tried) files are in the same folder as executable file. Want to note that in all other cases I tried except this one, Aspose.PDF works just fine under Mono.

internal class Program {
private static void Main(string[] args) {
using (var l = File.OpenRead("./Aspose.Total.lic")) {
new Aspose.Pdf.License().SetLicense(l);
}

using (var input = File.OpenRead("./example.pdf")) {
using (var output = File.Create("./output.pdf")) {
ConvertToPdfArchive(input, output);
}
}
}

private static void ConvertToPdfArchive(Stream input, Stream output) {
var pdfDocument = new Aspose.Pdf.Document(input);
using (var dummy = new MemoryStream()) {
try {
pdfDocument.Convert(dummy, PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
}
finally {
Console.WriteLine(Encoding.UTF8.GetString(dummy.ToArray()));
}
}
pdfDocument.Save(output);
}
}

Hi Evgeny,


Thank you for your inquiry. I am afraid Aspose.Pdf currently does not support mono on Linux, However,we have already logged a feature request PDFNEWNET-18915 in our issue tracking system for implementation. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,