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);
}
}