Embedding two Postscript fonts?

Hi,

The following code crashes in Aspose.Pdf (with both version 3.6.2.0 and 4.1.2.0). It tries to embed two postscript fonts. I can add a either Postscript font alone without any problems by commenting out the other, but when both fonts are there, it fails with the exception "The Font ‘Whitney-Light’ is not found. This font is not supported."

Can you please advise on the correct way to do this ?

Thank you very much,

Dominic.

///


/// Embedding PostScript Font
///

public static void TestAsposePdf08()
{
// Create PDF document
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.IsFontNotFoundExceptionThrown = true;

Aspose.Pdf.Section pdfSection;
pdfSection = pdf.Sections.Add();

Aspose.Pdf.Text pdfText;
Aspose.Pdf.Segment pdfSegment;

string str;

// Not embedded
pdfText = new Aspose.Pdf.Text(pdfSection);
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

pdfSegment.Content = “TEXT WITHOUT EMBEDDED FONT”;

// Extra content
pdfText = new Aspose.Pdf.Text(pdfSection);
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

str = “”;
str += “\n” + “Line 1” + “\n” + “Line 2”;
pdfSegment.Content = str;

// Embedded PostScript Font #1
Aspose.Pdf.TextInfo textInfoType1 = new Aspose.Pdf.TextInfo();
textInfoType1.FontSize = 18;
textInfoType1.FontName = “Whitney-Medium”;
textInfoType1.FontAfmFile = @“C:\dev\quicktest\App_data\Whitney-Medium.afm”;
textInfoType1.FontOutlineFile = @“C:\dev\quicktest\App_data\Whitney-Medium.pfb”;
textInfoType1.FontEncodingFile = @“C:\dev\quicktest\App_data\stdenc.txt”;
textInfoType1.FontEncoding = “stdenc”;
textInfoType1.IsFontEmbedded = true;

pdfText = new Aspose.Pdf.Text(pdfSection);
pdfText.TextInfo = textInfoType1;
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

pdfSegment.Content = “TEXT WITH EMBEDDED FONT (Whitney-Medium)”;

// Extra content
pdfText = new Aspose.Pdf.Text(pdfSection);
pdfText.TextInfo = textInfoType1;
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

str = “”;
str += “\n” + “Line 1” + “\n” + “Line 2”;
pdfSegment.Content = str;

// Embedded PostScript Font #2
Aspose.Pdf.TextInfo textInfoType2 = new Aspose.Pdf.TextInfo();
textInfoType2.FontSize = 18;
textInfoType2.FontName = “Whitney-Light”;
textInfoType2.FontAfmFile = @“C:\dev\quicktest\App_data\Whitney-Light.afm”;
textInfoType2.FontOutlineFile = @“C:\dev\quicktest\App_data\Whitney-Light.pfb”;
textInfoType2.FontEncodingFile = @“C:\dev\quicktest\App_data\stdenc.txt”;
textInfoType2.FontEncoding = “stdenc”;
textInfoType2.IsFontEmbedded = true;

pdfText = new Aspose.Pdf.Text(pdfSection);
pdfText.TextInfo = textInfoType2;
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

pdfSegment.Content = “TEXT WITH EMBEDDED FONT (Whitney-Light)”;

// Extra content
pdfText = new Aspose.Pdf.Text(pdfSection);
pdfText.TextInfo = textInfoType2;
pdfSection.Paragraphs.Add(pdfText);

pdfSegment = new Aspose.Pdf.Segment(pdfText);
pdfText.Segments.Add(pdfSegment);

str = “”;
str += “\n” + “Line 1” + “\n” + “Line 2”;
pdfSegment.Content = str;

string asmVersion = typeof(Aspose.Pdf.Pdf).Assembly.GetName().Version.ToString();
pdf.Save(“c:\temp\pdfTest08-v” + asmVersion + “.pdf”);
}


Hello Dominic,

Sorry for replying you late.

I have tested the scenario using Aspose.Pdf for .NET 4.1.2 and I’m able to reproduce the same problem. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The issues you have found earlier (filed as 14503) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.