Ok, so I am trying to change the font size on a Text paragraph in a table cell. My code looks like this:
foreach(Row row in table.Rows) {
foreach(Cell cell in row.Cells) {
foreach(Text text in cell.Paragraphs) {
text.TextInfo.FontSize *= 0.8; // I want to scale the font down by 80%
foreach(Segment seg in text.Segments) // For good measure I try doing it to every segment too.
seg.TextInfo.FontSize *= 0.8;
}}}
What am I doing wrong? I’ve tried all sorts of things, and I just cannot get the font size to decrease. IN case it matters I am setting text.FontName = “Arial”; too.
Here’s the exact code I’m using (there’s a good deal before this). I’ve commented out the lines I was trying to make my scaling work (scale is a float higher than 0 and lower than 1).
// Apply scaling to row heights.
foreach(Row row in table.Rows)
{
row.FixedRowHeight *= scale;
foreach(Cell cell in row.Cells)
{
// Apply scaling to font sizes.
foreach(Text text in cell.Paragraphs)
{
//text.TextInfo.FontName = "Arial";
//text.TextInfo.FontSize = /* round down --> */(int)(text.TextInfo.FontSize * scale);
foreach(Segment seg in text.Segments)
{
TextInfo info = new TextInfo();
info.FontSize = 4;
info.FontName = "Arial";
seg.TextInfo = info;
}
//text.TextInfo.FontName = "Arial";
}
}
}
Attached is a PDF generated by my code. Obviously the text in it is not 4pts. Is something else going on?
Gah… Figured it out, in some arcane corner I was accidentally setting the FontSize back to 11. This works now <_<
Thanks for your time (sorry to waste it). You guys provide some very quick CS, and I appreciate it (and it’s one of the factors that decided which components to use on my project). Thanks again.