I am running your demo on a html file generated by one of our systems. We are trying to verify that this solution will work for us, but running into this hopefully small issue.
It is referencing the font “Univers Condensed” inside the markup. The font is specified in a Font tag, but other font options are in styles that are scripted in the html.
Upon getting the error, I modified the demo code to the following:
case “HTML_FILE”:
{
// add the section to PDF document sections collection
Section section = pdf1.Sections.Add();
// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(Source_HTML_File);
//Create text paragraphs containing HTML text
Text text2 = new Text(section, r.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
foreach (Segment segment in text2.Segments)
{
if (segment.TextInfo != null)
{
segment.TextInfo.FontName = “Univers Condensed”;
segment.TextInfo.IsFontEmbedded = true;
}
}
text2.TextInfo.FontName = “Univers Condensed”;
text2.TextInfo.IsFontEmbedded = true;
// Add the text object containing HTML contents to PD Sections
section.Paragraphs.Add(text2);
// save the resultant PDF
pdf1.Save(afileName);
// return the reusltant PDF
return pdf1;
The modifications did not change the outcome. Is there a different place that I need to specify the embedded font? There are no errors generated in specifying it, but when the save is performed, it fails.
I verified that the name that I have used is the same as the name in the Fonts Control Panel for Univers Condensed. This font is specified to us and not negotiable.
Thanks for any assistance!
Robb
I tried the sample in the Technical Articles and modified it thus ( to put it in the same edit spot):
//Create a section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Create a text paragraph inheriting text format settings from the section
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);
//Add the text paragraph to the section
sec1.Paragraphs.Add(text1);
//Create a text segment
Aspose.Pdf.Generator.Segment s1 = new Aspose.Pdf.Generator.Segment(" This is a sample text using Custom font");
//Set the font name to the TextInfo.FontName property of segment, where ‘Almonto Snow’ is custom font name
s1.TextInfo.FontName = “Univers Condensed”;
// Set the value for property to include the font description into Pdf file
s1.TextInfo.IsFontEmbedded = true;
//Add the text segment to the text paragraph
text1.Segments.Add(s1);
//Save the Pdf
pdf1.Save(afileName);
return pdf1;
The result was:
The embedded font ‘Univers Condensed’ is not found. Make sure that you set correct path to the font file. I found this confusing since the Font is a True Type font and is installed properly.
Hope this helps…
Robb
I also added this line and it had no effect:
s1.TextInfo.TruetypeFontFileName = @“C:\WINDOWS\Fonts\unvr57w.ttf”;
Hi Robb,
Thanks for using our products and sharing the sample source code with us. I tested the scenario and able to notice the same problem. For rectification, I logged this problem with ID: PDFNEWNET-33722 in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.
We apologize for your inconvenience.
Thanks & Regards,
Hi Rashid,
Hi Bipin,
Sorry for the inconvenience faced. I have verified the status of the reported issue and regret to share that this issue is pending for resolution due to its complexity and other priority issues. I have requested the resolution ETA from the development team and as soon as I get a feedback, I will update you via this forum thread.
Thanks for your patience and understanding.
Best Regards,
The issues you have found earlier (filed as PDFNEWNET-33722) have been fixed in Aspose.Pdf for .NET 7.7.0.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
[quote user=“aspose.notifier”]
The issues you have found earlier (filed as PDFNEWNET-33722) have been fixed in Aspose.Pdf for .NET 7.7.0.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.[/quote]
I am getting this exact same error with the latest build, 8.7. Are you recommending I rollback to 7.7?
Hi Scott,