We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bad font object or font descriptor

Hi We have aspose licence andw we are using it to convert office document to pdf and append html but converted document open fine in browser but when opening in adobe pdf reader it has below messsage.

“Bad font object or font descriptor”. once clicking OK user can see converted pdf.

We have below code to append html.

`Aspose.Pdf.Document doc = new Aspose.Pdf.Document(outMemStrm);

                                        var htmlFilePath = GetTemporaryDirectory() + "\\html.pdf";
                                        
                                        HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
                                        var docHtml =
                                            new Document(
                                                new MemoryStream(System.Text.Encoding.UTF8.GetBytes(convDoc
                                                    .HTMLToAppend)), htmlLoadOptions) {EmbedStandardFonts = true};
                                        docHtml.Save(htmlFilePath);

                                        Page page = null;
                                        switch (convDoc.HTMLToAppendLocation)
                                        {
                                            case RoutingMessageDocument.HTMLLocation.Beginning:
                                                doc.Pages.Insert(1, docHtml.Pages[1]);
                                                break;
                                            case RoutingMessageDocument.HTMLLocation.End:
                                                doc.Pages.Add(docHtml.Pages[1]);
                                                break;
                                            case RoutingMessageDocument.HTMLLocation.Page:
                                                doc.Pages.Insert(convMessage.ConcatenatedHTMLToAppendPage, docHtml.Pages[1]);
                                                break;
                                            default:
                                                page = doc.Pages.Add();
                                                break;
                                        }

                                        doc.Save(outMemStrm);`

@kp39,

Thanks for contacting support.

Can you please confirm if the problem is occurring for specific set of documents or it is occurring for all the files.

Also please share the sample PDF documents so that we can test the scenario in our environment. We are sorry for this inconvenience.

@codewarior, it happens for all files, I have attached, word document, html and converted pdf.

Aspose.zip (881 Bytes)

@kp39,
In the source code, you are inserting a page of one document into another document, whereas you have shared a single HTML document with us. Kindly share all details, including input documents and the simplified code snippet. The Concatenate method of the PdfFileEditor class allows to concatenate two documents. Please try to concatenate your documents in this way and let us know how that goes into your environment. Please refer to this help topic: Concatenate multiple PDF files using MemoryStreams

Best Regards,
Imran Rafique

@imran.rafique thanks for reply, we have requirement to add html to at given page. I have tried via PdfEditor and it is still same. We have followed below approach

  1. Read Source document in to memory stream(Origninal_Document.docx)
  2. Convert Html to Document(Html2Append.html)
  3. Insert converted html page at given page number on PDF memory stream from step 1
  4. Save document(Converted.pdf)

Aspose.zip (88.3 KB)

@kp39,
Your source code is not in fully compilable form and using unknown values of objects with a switch case in the code. Aspose.Pdf for .NET API cannot import Word documents, since you require Aspsoe.Words API to convert your source Word document. Aspose.Words for .NET API can import both Word and HTML documents, append them and then save in the PDF format. You can achieve the requirement with the latest version 17.7 of Aspose.Words for .NET API as below:

Output PDF: OutputPDF.pdf (54.8 KB)

[C#]

// load source documents
Document wordDocument = new Document(@"C:\Pdf\test194\Origninal_Document.docx");
Document htmlDocument = new Document(@"C:\Pdf\test194\Html2Append.html");
// append documents
htmlDocument.AppendDocument(wordDocument, ImportFormatMode.UseDestinationStyles);
// save document in the PDF format
htmlDocument.Save(@"C:\Pdf\test194\OutputPDF.pdf", Aspose.Words.SaveFormat.Pdf);

Furthermore, kindly simplify your source code and share with us again because it will help us to identify the root cause of this error.

Best Regards,
Imran Rafique

@imran.rafique
We do not use Aspose.Pdf for .Net API to import word, We have logic to convert different document type(word, visio, ppt) to pdf first and then we add html to converted pdf.

When we add html to converted pdf that is where we have font error.

@kp39,
Well, in that way, you have shared an input Word document, HTML document and a single output PDF document. Kindly share an input PDF document in which you are inserting an HTML string along with the simplified code snippet, so that we could replicate this error in our environment. Once you will provide all the required details, then we would be able to investigate it further in our environment. Your response is awaited.

Best Regards,
Imran Rafique

@imran.rafique, thanks for reply, we were able to identify proble, It was not aspose but Azure api which corrupted file while uploading to file storage. thanks for all help, we do have another issue now as we need to repair all files previously generated and not sure if there is way via aspose api? user can open converted pdf file in Edge browser and chrome browser but in adobe reader and ie cannot open. I have attache sample file. if you please let me know if there is way to recover file via aspose api that would be great.DeleteMe.pdf (135.2 KB)

@kp39,
Thank you for the details. We are working over your query and will get back to you soon.

Best Regards,
Imran Rafique

@kp39,
We have logged an investigation to fix the problem of font objects under the ticket ID PDFNET-43178 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.

Best Regards,
Imran Rafique

@imran.rafique

Thanks for very quick reply, do we have any update on above please?

@kp39,
The linked ticket ID PDFNET-43178 has just been identified and pending for analysis. Our product team will investigate as per the development schedule. We will let you know once a significant progress has been made in this regard.

Best Regards,
Imran Rafique

@imran.rafique, Is there any update on ticket? Can you please let us know as we need to have solution asap, any help is very much appreciated

@kp39,
The linked ticket ID PDFNET-43178 is pending for the analysis and not resolved yet. Our product team will investigate as per the development schedule. We will let you know once a significant progress has been made in this regard.