Error while opening pdf created by Aspose (Cannot find or create the font 'QCOQAT+TimesNewRoman'. Some characters may not display or print correctly. )

we have a form pdf which gets appended to another pdf. When opening the combined pdf, we get this error.

Cannot find or create the font ‘QCOQAT+TimesNewRoman’. Some characters may not display or print correctly.

The font name changes slighty everytime like with some random 6 chars before the plus sign like abcxyz+TimesNewRoman.

This error comes only when opening the PDF in adobe. When opening directly using browser it works fine as no error is reported by browser.

Why this happens? It does not happen in all other cases where we combine with normal PDFs.

Any workaround to get this error go away?

With Best Regards
Sayee

Hi @Sayee,

Please, can you upload on this ticket your input files and the code that you are using to “merge” the documents? I would also like to know the version of Aspose.PDF that you are using.

[]'s

Hi
thank you for quick response. Unfortunately - the form in question is having some sensitive personal information and not suitable for sharing in support forum. However, i can confirm it sounds like a bug, as we are able to workaround the issue by doing something like below.

basically
we have 3 steps:

  1. a pdf (generated by converting some other file to PDF by ASPOSE total) - call it main.pdf
  2. a pdf which is a dynamic form pdf, call it attachment.pdf
  3. a method will concat attachment.pdf to the end of main.pdf

this process works fine for all other files, but when #2 is an dynamic form pdf it does not work by default (due to xfa form limitations) as this is not handled properly by default in ASPOSE, so we have to write a helper method to process the #2 attachment.pdf like below
public static Aspose.Pdf.Document ByteArrayToPdf(this byte[] attachmentAsPdfByteArray)
{
var msPdf = new MemoryStream(attachmentAsPdfByteArray);
var attachmentAsPdf = new Aspose.Pdf.Document(msPdf);

        //fix to handle aspose-issue for dynamic form pdf - start 
        //refer https://docs.aspose.com/pdf/net/xfa-forms/#convert-xfa-to-acroform
        if (attachmentAsPdf.Form.Type == Aspose.Pdf.Forms.FormType.Dynamic)
        {
            attachmentAsPdf.Form.Type = Aspose.Pdf.Forms.FormType.Standard; 
            attachmentAsPdf.Flatten(); //need the form as printed
        }
        //fix to handle aspose-issue for dynamic form pdf - end
        return attachmentAsPdf;
    }

now aspose can handle the dynamic form pdf and the resultant combined pdf is ok in looks, but creates an error in adobe viewer.
image.png (5.1 KB)
This is the issue we reported in this thread.

But we could work around this issue - by saving the attachment.pdf and reopening it again, somehow magically the issue is resolved and adobe is no longer complaining about the pdf generated after concatenation. We believe this should be unnecessary step and purely workaround and imply a bug in aspose, Please consider for fixing in future release.

Fixed code with workaround:
public static Aspose.Pdf.Document ByteArrayToPdf(this byte[] attachmentAsPdfByteArray)
{
var msPdf = new MemoryStream(attachmentAsPdfByteArray);
var attachmentAsPdf = new Aspose.Pdf.Document(msPdf);

    //fix to handle aspose-issue for dynamic form pdf - start
    //refer https://docs.aspose.com/pdf/net/xfa-forms/#convert-xfa-to-acroform
    if (attachmentAsPdf.Form.Type == Aspose.Pdf.Forms.FormType.Dynamic)
    {
        attachmentAsPdf.Form.Type = Aspose.Pdf.Forms.FormType.Standard;
        attachmentAsPdf.Flatten();  //need the form as printed
        
        //workaround to handle font error in adobe - cannot find or create the font - START
        var byteArray = attachmentAsPdf.SaveAsByteArray(); //helper method to convert pdf to byte[] using a memory stream
        return byteArray.ByteArrayToPdf(); //called recursively, but this time it wont be dynamic form instead standard form
        //workaround to handle font error in adobe - cannot find or create the font - END
    }
    //fix to handle aspose-issue for dynamic form pdf - end
    return attachmentAsPdf;
}

With Best regards
Sayee

Hi @Sayee,

Thanks for sharing this info. I will open a ticket to fix this issue in Aspose.PDF and let you know when it will be available.

Ticket PDFJAVA-42114 was created for this issue

1 Like