Free Support Forum -

Unexpected font parsing exception when running PdfEditor.Concatenateon AWS Lambda


I’m using Apose.Words and Aspose.PDF for C#.

I have a project that converts a bunch of Word documents to PDFs, and then attempts to concatenate those PDFs into a single document. It works fine on my local Windows box, but when I deploy to AWs and try to run the Concatenation, I get:

Unexpected font parsing exception —> System.IO.DirectoryNotFoundException: Could not find a part of the path ‘/usr/share/fonts/truetype/msttcorefonts’.

I’ve been researching all night and am at a dead end. How do I correct this so I can run this function in the AWS Lambda Unbuntu environment?

I can give you access to the GitHub repo hosting the C# Lambda function, the code is short and straightforward.




Thank you for contacting support.

Would you please specify if the exception is being thrown by Aspose.Words for .NET or Aspose.PDF for .NET API. Please also share narrowed down code snippet reproducing this issue so that we may try to reproduce and investigate it in our environment.


The exception is coming from the PdfEditor. Here’s the code:

var pdfEditor = new PdfFileEditor();

      //  pdfEditor.CorruptedFileAction = Aspose.Pdf.Facades.PdfFileEditor.ConcatenateCorruptedFileAction.ConcatenateIgnoringCorrupted;
        pdfEditor.AllowConcatenateExceptions = true;


        using (MemoryStream pdfStream = new MemoryStream())
            Console.WriteLine($"Creating a PDF from {documents.Count} documents");

            var inMemoryDocuments = documents.ToArray();
            Console.WriteLine($"Stream 1 has {inMemoryDocuments[0].Length} bytes");
            var result = pdfEditor.Concatenate(inMemoryDocuments, pdfStream);

            if (!result)
                Console.WriteLine("Warning: Concatenation failure detected");
                throw pdfEditor.LastException;

            if (pdfEditor.CorruptedItems != null && pdfEditor.CorruptedItems.Length > 0)
                Console.WriteLine("Corrupted documents:");
                foreach (Aspose.Pdf.Facades.PdfFileEditor.CorruptedItem item in pdfEditor.CorruptedItems)
                { Console.WriteLine(item.Index + " reason " + item.Exception.Message); }

            // and we're good
            var buffer = pdfStream.ToArray();

            Console.WriteLine("Combined document is " + buffer.Length + " bytes");
            await wc.UploadDataTaskAsync(request.OutputUri, "PUT", buffer);


Again - this works fine on Windows, but errors out on AWS Lambda, which I think is an Ubuntu environment.



Thank you for sharing further details.

We have logged a ticket with ID PDFNET-45891 in our issue management system for further investigations about DirectoryNotFoundException for default folder by Aspose.PDF for .NET. We will let you know as soon as some significant updates will be available in this regard.