Problem: The attached document is only 1MB in size, having 84 pages. Converting this to PDF/A takes 90 seconds. Can this be improved given the simplicity of the document?
Host: Win11
Runtime: .NET 6
Library: Aspose.Drawing.Pdf 23.4.0 and 23.5.0
Mode: Release
Free_Test_Data_1MB_PDF (1).pdf (1.0 MB)
Code
using PdfDocument = Aspose.Pdf.Document;
using var inputPdfFileStream = File.OpenRead(inputFilename);
var document = new PdfDocument(inputPdfFileStream);
AllowPrintDocumentPrivilege(document);
var timestamp = $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}";
var convertLogFilename = $"{timestamp}_{inputFilename}_convert.log";
var outputFilePath = Path.Combine(outputPath.FullName, $"{inputFilename}_{timestamp}.pdf");
document.Convert(convertLogFilename, pdfFormat, ConvertErrorAction.Delete);
document.Save(outputFilePath, CreateSaveOptions());
private static void AllowPrintDocumentPrivilege(Document document)
{
var fileSecurity = new PdfFileSecurity(document);
fileSecurity.SetPrivilege(DocumentPrivilege.AllowAll);
}
private static PdfSaveOptions CreateSaveOptions() => new()
{
DefaultFontName = "Arial"
};