Font 'Times New Roman' not found. Please make sure the customer font file is correctly set

We are trying to combine Image file (.jpg), it throw error.


Note: It is working for PDF/Doc/Cells.


Error Msg:

An exception of type ‘System.ApplicationException’ occurred in Aspose.Pdf.dll but was not handled in user code

Additional information: The embedded font ‘Times New Roman’ is not found. Make sure that you set correct path to the font file.

Hi Jothikumar,


Thanks for contacting support.

Can you please share some details regarding the operation you are performing and the code snippet along with input documents, so that we can test the scenario in our environment. We are sorry for this inconvenience.
foreach (var fullFilePath in fullFilePathsOnDisk)
{
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense("Aspose.Pdf.lic");

Aspose.Words.License wordLicense = new Aspose.Words.License();
wordLicense.SetLicense("Aspose.Words.lic");

Aspose.Cells.License cellLicense = new Aspose.Cells.License();
cellLicense.SetLicense("Aspose.Cells.lic");

var sectionPDF = new Aspose.Pdf.Document();

using (MemoryStream sectionStream = new MemoryStream())
{


if (i > 0 && IsImage(fullFilePathsOnDisk[i - 1]) && !skippedOneFile)
{
i++;
skippedOneFile = true;
continue;
}
skippedOneFile = false;
if (i < fullFilePathsOnDisk.Count - 1)
{
isNextFileImage = IsImage(fullFilePathsOnDisk[i + 1]);
}
Aspose.Pdf.Generator.Pdf imagePDF = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = imagePDF.Sections.Add();
section.IsLandscape = false;
Aspose.Pdf.Generator.Image topImage = new Aspose.Pdf.Generator.Image(section);
var topFileName = new Aspose.Pdf.Generator.Text(Path.GetFileName(fullFilePath));
topFileName.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;
section.Paragraphs.Add(topFileName);
section.Paragraphs.Add(topImage);
section.PageInfo.Margin = new Aspose.Pdf.Generator.MarginInfo() { Top = 100, Left = 50, Right = 50, Bottom = 50 };

var border = new Aspose.Pdf.Generator.GraphInfo();
border.Color = new Aspose.Pdf.Generator.Color("black");

topImage.ImageInfo.ImageBorder = new Aspose.Pdf.Generator.BorderInfo() { Left = border, Right = border, Bottom = border, Top = border };

topImage.ImageInfo.ImageFileType = GetImageTypeForAspose(fullFilePath);
topImage.ImageInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

SetImageSize(topImage, section.PageInfo.PageHeight, section.PageInfo.PageWidth, fullFilePath);



using (Stream jpegStream = new BufferedStream(new FileStream(fullFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
{
topImage.ImageInfo.ImageStream = jpegStream;
imagePDF.Save(sectionStream);
}
}

}

Any image file (.jpg)

Hi Jothikumar,

Thanks for sharing the details.

I have tested the scenario using Aspose.Pdf for .NET 17.3.0 in Visual Studio 2015 project with .NET Framework 4.5.2 running over Windows 10 where I have used one of my sample Image files and I am unable to notice any issue. In above code snippet, there are some variables and a method SetImageSize(…) which is not defined, so I commented out these code lines and resultant file is properly being generated.

Can you please try using latest release version and in case you still face the same issue, please share a sample project, so that we can further investigate the issue in our environment. We are sorry for this inconvenience.

C# code

var sectionPDF = new Aspose.Pdf.Document();

using (MemoryStream sectionStream = new MemoryStream())
{
    /* if (i > 0 && IsImage(fullFilePathsOnDisk[i - 1]) && !skippedOneFile)
    {
        i++;
        skippedOneFile = true;
        continue;
    }

    skippedOneFile = false;
    if (i < fullFilePathsOnDisk.Count - 1)
    {
        isNextFileImage = IsImage(fullFilePathsOnDisk[i + 1]);
    }*/

    Aspose.Pdf.Generator.Pdf imagePDF = new Aspose.Pdf.Generator.Pdf();
    Aspose.Pdf.Generator.Section section = imagePDF.Sections.Add();

    section.IsLandscape = false;

    Aspose.Pdf.Generator.Image topImage = new Aspose.Pdf.Generator.Image(section);

    var topFileName = new Aspose.Pdf.Generator.Text("c:/pdftest/PDF_A_1a_ComplianceCheck.PNG");
    topFileName.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

    section.Paragraphs.Add(topFileName);
    section.Paragraphs.Add(topImage);
    section.PageInfo.Margin = new Aspose.Pdf.Generator.MarginInfo() { Top = 100, Left = 50, Right = 50, Bottom = 50 };


    var border = new Aspose.Pdf.Generator.GraphInfo();
    border.Color = new Aspose.Pdf.Generator.Color("black");

    topImage.ImageInfo.ImageBorder = new Aspose.Pdf.Generator.BorderInfo() { Left = border, Right = border, Bottom = border, Top = border };
    topImage.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;//= GetImageTypeForAspose(fullFilePath);
    topImage.ImageInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

    // SetImageSize(topImage, section.PageInfo.PageHeight, section.PageInfo.PageWidth, fullFilePath);
    using (Stream jpegStream = new BufferedStream(new FileStream("c:/pdftest/Shrink_OverSized_Option_Selected.PNG", FileMode.Open, FileAccess.Read, FileShare.Read)))
    {
        topImage.ImageInfo.ImageStream = jpegStream;
        imagePDF.Save("c:/pdftest/ResultantFile.pdf");
    }
}

// sectionPDF.Save("c:/pdftest/ResultantFile.pdf");