ASPOSE DLL throwing error as "Invalid Font Name"

Hi,

We have licensed version of ASPOSE. Facing problem processing PDF files. The error throwing is “Invalid font name”.

From the error text we get that there are some fonts in those PDF files which ASPOSE is not able to identify.

Could you help us to fix this quickly as it is impacting the business users.

Thanks in advance.

Regards,
Sanjay

@sanjayadsure,

Kindly share the complete details of the scenario, including source PDF and code. We will investigate and share our findings with you.

Hi,

Thank you for the reply. Please find attached one of the PDFs we are facing issue with.

There is a scenario where we are looping through each page of PDF and below line is throwing issue.

//Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);

Exception thrown is “Invalid font name”

Thanks,
Sanjay
Sciences Scavenger Hunt (subject guide).pdf (91.8 KB)

@sanjayadsure,

We have tested your source PDF with the latest version 17.12 of Aspose.Pdf for .NET API and unable to replicate this error in our environment. Kindly share the complete code with us. We will investigate and share our findings with you.

Hi,

To check the scenario with latest version, after your reply, I downloaded your latest ASPOSE Total For .NET having version as 17.9.0.0 and added it.
But came to know that ASPOSE.PDF.Generator is Obsolete now.

Can you tell me what can I use in below scenarios?

//For adding the selected image to PDF

Aspose.Pdf.Generator.Pdf pdfGen = new Aspose.Pdf.Generator.Pdf();

// Create a section in the PDF object
Aspose.Pdf.Generator.Section pdfGenerateSec = pdfGen.Sections.Add();

// Create an image object in the section
Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image(pdfGenerateSec);

//Center allign the image
img.ImageInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

Thanks,
Sanjay

@sanjayadsure,

Please use Document, Page, TextFragment, TextParagraph, TextBuilder, XImage in place of Pdf, Section, Image classes. Please refer to these help topics: Add Text in an Existing PDF File and Add Image to Existing PDF File

In order to understand the new DOM approach, please go through this help topic: Introduction to the DOM API. This is the complete developer guide of the new DOM approach: Working with Aspose.Pdf.

Hi,

We have modified above code as below for latest DLL.

//For adding the selected image to PDF

           Aspose.Pdf.Document pdfGen = new Aspose.Pdf.Document();

            // Create a section in the Pdf object
            Aspose.Pdf.Page pdfGenerateSec = pdfGen.Pages.Add();

            // Create an image object in the section
            Aspose.Pdf.Image img = new Aspose.Pdf.Image();

            // Center allign the image
           img.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

Let us know if it’s as per updated classes?

And another problem I am facing is the license file. As the license file is valid but works with old DLL it’s giving error with new DLL (as I am using for testing purpose.).
Can you tell me the steps how can I get free license file to test our scenario? I tried the steps mentioned on site but not able to get free license file.

For time being I have skipped the license verification but now it’s showing
An exception of type ‘System.IndexOutOfRangeException’ saying
Additional information: At most 4 elements (for any collection) can be viewed in evaluation mode.

Thanks,
Sanjay

@sanjayadsure,

Yes, the code looks fine.

You can get a 30 day temporary license from the purchase portal and its option is available in step 5. A temporary license is a time-restricted full license that lets you test every aspect of the API before renewing or buying it.

Please get and apply the temporary license and if this does not help, then kindly send all details of the scenario, including source PDF and code. We will investigate and share our findings with you.

Hi,
As per your suggestion, we were able to download the temp license & checked with Aspose.PDF with version 17.9.0.0 but still facing same error as “Invalid Font Name”.

Below is the code we are using for Creating Page number & adding it to particular position of each page.

public static Aspose.Pdf.Document CreatePageNumbers(Aspose.Pdf.Document newDocument)
{
try
{
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();

            if (newDocument.Pages.Count > 0)
            {
                for (int i = 1; i <= newDocument.Pages.Count; i++)
                {
                    //Get particular page
                    Page pdfPage = newDocument.Pages[i];

                    //Create text fragment for Page Number
                    TextFragment textFragment = new TextFragment((i + 1) + "/" + (newDocument.Pages.Count + 1));
                    textFragment.Position = new Position(510, 30);

                    //Set text properties
                    textFragment.TextState.FontSize = 12;
                    textFragment.TextState.FontStyle = FontStyles.Bold;

                    textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.DarkGray);

                    //Create TextBuilder object
                    TextBuilder textBuilder = new TextBuilder(pdfPage);

                    //Append the text fragment to the PDF page
                    textBuilder.AppendText(textFragment);


                    pdfDocument.Pages.Add(pdfPage);
                }
            }
            return pdfDocument;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

As mentioned in our earlier posts, we are getting error as below line
//Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);

@sanjayadsure,

We have tested CreatePageNumbers method using a sample PDF document and could not replicate an error in our environment. The 17.9.0.0 is an old version, please download and try the latest version 17.12 of Aspose.Pdf for .NET API. If this does not help, then kindly send us your source PDF document. We will investigate and share our findings with you.

Hi,

We have already attached the PDF in older posts. Can you please use it with CreatePageNumbers method?

Thanks,
Sanjay

@sanjayadsure,

We have tested your source PDF with the latest version 17.12 of Aspose.Pdf for .NET API and could not replicate the said error in our environment. This is the output PDF document: Output17.12.pdf (70.8 KB)

Hi,

Now tried with latest version of ASPOE.PDF for .NET that is 17.12 and it’s not giving above error.

Now if we have to use this latest version do we need to get new license or it will work with our existing license?

Thanks,
Sanjay

@sanjayadsure,

You can open the license file with notepad and will see a subscription expiry tag. If the license expiry date is greater than the release date of version 17.12 of Aspose.Pdf for .NET API, then it is a valid license, otherwise you need to renew the license. Please refer to the renewal policies: