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

Free Support Forum - aspose.com

Font changes in multi line cell- pdf can't be printed from IE

With the code below the cell containing our description string is split into three lines but the middle line is in the wrong font. Additionally when printing this from MS Edge (or IE) the printer produces an error. The latter may or may not be related to the former problem.


How can I get the fonts to be correct? And why does it not print in some viewers? Note that reloading the pdf into a new Document object loads a page with no paragraphs.


Document pdf = new Document();
var mainPage = pdf.Pages.Add();

var textFont = FontRepository.FindFont(“Helvetica”);

pdf.PageInfo.DefaultTextState = new TextState { Font = textFont};

mainPage.SetPageSize(597.6, 842.4);
mainPage.PageInfo.Margin = new MarginInfo { Left = 42, Right = 42, Top = 120, Bottom = 73 };
mainPage.PageInfo.DefaultTextState = new TextState { Font = textFont, FontSize = 10 };

var itemTable = new Table
{
ColumnWidths = “50 200 65 85 55”,
Margin = new MarginInfo { Left = 15, Right = 12, Top = 35, Bottom = 10 },
DefaultCellTextState = { Font = textFont, FontSize = 10 },
RepeatingRowsCount = 1,
IsBroken = true
};

var headerRow = itemTable.Rows.Add();
headerRow.DefaultCellTextState.Font = FontRepository.FindFont(“Helvetica-Bold”);

headerRow.Cells.Add(“Quantité”);
headerRow.Cells.Add(“Description”);

var hdrUnit = headerRow.Cells.Add(“PU HT”);
hdrUnit.Alignment = HorizontalAlignment.Right;

var hdrNet = headerRow.Cells.Add(“Total HT”);
hdrNet.Alignment = HorizontalAlignment.Right;

var hdrTax = headerRow.Cells.Add(“TVA”);
hdrTax.Alignment = HorizontalAlignment.Right;

var itemRow1 = itemTable.Rows.Add();

itemRow1.Cells.Add(“6”);

itemRow1.Cells.Add(“2 x Locations balises et frais de Communication pour 3 mois à partir du 15 Août 2010.”);

var numUnit = itemRow1.Cells.Add(“1,10 €”);
numUnit.Alignment = HorizontalAlignment.Right;

var numNet = itemRow1.Cells.Add(“6,60 €”);
numNet.Alignment = HorizontalAlignment.Right;

var numTax = itemRow1.Cells.Add(“3,30 €”);
numTax.Alignment = HorizontalAlignment.Right;
mainPage.Paragraphs.Add( itemTable);

Hi Oliver,


Thanks for your inquriy. I am afraid I do not have Helvetica font installed on my system so I have tested the scenario with Book Antiqua font using Aspose.Pdf for .NET 17.1.0 and unable to notice both issues font difference and printing form IE. If you are using some old version then please download and try latest version of Aspsoe.Pdf for .NET, it will resolve the issue. However if the issue persist then please share your sample font and output file here, we will investigate the issue.

Aspose.Pdf.Document
pdf = new Aspose.Pdf.Document();<o:p></o:p>

var mainPage = pdf.Pages.Add();

var textFont = FontRepository.FindFont("Book Antiqua");

pdf.PageInfo.DefaultTextState = new TextState { Font = textFont };

mainPage.SetPageSize(597.6, 842.4);

mainPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo { Left = 42, Right = 42, Top = 120, Bottom = 73 };

mainPage.PageInfo.DefaultTextState = new TextState { Font = textFont, FontSize = 10 };

var itemTable = new Aspose.Pdf.Table

{

ColumnWidths = "50 200 65 85 55",

Margin = new Aspose.Pdf.MarginInfo { Left = 15, Right = 12, Top = 35, Bottom = 10 },

DefaultCellTextState = { Font = textFont, FontSize = 10 },

RepeatingRowsCount = 1,

IsBroken = true

};

var headerRow = itemTable.Rows.Add();

headerRow.DefaultCellTextState.Font = FontRepository.FindFont("Book Antiqua Bold");

headerRow.Cells.Add("Quantité");

headerRow.Cells.Add("Description");

var hdrUnit = headerRow.Cells.Add("PU HT");

hdrUnit.Alignment = HorizontalAlignment.Right;

var hdrNet = headerRow.Cells.Add("Total HT");

hdrNet.Alignment = HorizontalAlignment.Right;

var hdrTax = headerRow.Cells.Add("TVA");

hdrTax.Alignment = HorizontalAlignment.Right;

var itemRow1 = itemTable.Rows.Add();

itemRow1.Cells.Add("6");

itemRow1.Cells.Add("2 x Locations balises et frais de Communication pour 3 mois à partir du 15 Août 2010.");

var numUnit = itemRow1.Cells.Add("1,10 €");

numUnit.Alignment = HorizontalAlignment.Right;

var numNet = itemRow1.Cells.Add("6,60 €");

numNet.Alignment = HorizontalAlignment.Right;

var numTax = itemRow1.Cells.Add("3,30 €");

numTax.Alignment = HorizontalAlignment.Right;

mainPage.Paragraphs.Add(itemTable);

pdf.Save(myDir+"table_font1.pdf");


We are sorry for the inconvenience.

Best Regards,