Hi,
I generated a table using the library, but the data didn't show on Adobe Reader IX, it works fine if using other PDF reader or view via URL.
Could anyone know what's the problem?
Thanks in advance.
Eileen
Here is my code:
private void DrawInvoiceItemsTable(PdfContents contents, Invoice invoice)
{
contents.SaveGraphicsState();
contents.Translate(0, 0);
const double col1X = 2.2;
const double baseY = 19.25;
const double col2X = 11.1;
const double col5X = 16;
contents.SetColorNonStroking(Color.FromArgb(40, 171, 226));
contents.DrawRectangle(1.9, 19, 8.5, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col1X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "ITEM DESCRIPTION");
contents.DrawRectangle(10.45, 19, 4.2, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col2X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "POINTS ISSUED");
contents.DrawRectangle(14.7, 19, 5.5, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col5X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "TOTAL AMOUNT");
contents.RestoreGraphicsState();
var box = new TextBox(7.9);
var posY = 18.6;
const double fontSize = 9.0;
var lineSpace = ArialNormal.LineSpacing(fontSize);
var decent = ArialNormal.Descent(fontSize);
const double lineHeight = 0.3;
contents.SaveGraphicsState();
contents.Translate(0, 0);
for (var i = 0; i < invoice.InvoiceCharges.Count; i++)
{
box.Clear();
if (i % 2 != 0)
{
contents.SetColorNonStroking(Color.FromArgb(230, 230, 230));
contents.DrawRectangle(1.9, posY - lineSpace * 1.5, 8.5, lineHeight + lineSpace, PaintOp.Fill);
contents.DrawRectangle(10.45, posY - lineSpace * 1.5, 4.2, lineHeight + lineSpace, PaintOp.Fill);
contents.DrawRectangle(14.7, posY - lineSpace * 1.5, 5.5, lineHeight + lineSpace, PaintOp.Fill);
}
box.AddText(ArialNormal, fontSize, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].Description);
contents.DrawText(col1X, ref posY, 0, 0, box);
posY += decent;
contents.DrawText(ArialNormal, fontSize, col2X, posY, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].PointsIssued);
contents.DrawText(ArialNormal, fontSize, col5X, posY, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].Amount.ToString("c2"));
posY -= decent + lineSpace;
}
contents.DrawText(ArialNormal, 10.0, 15.2, 6.5, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), "Subtotal");
contents.DrawText(ArialNormal, 10.0, 19, 6.5, TextJustify.Right, DrawStyle.Normal, Color.Black, invoice.SubTotal.ToString("c2"));
contents.DrawText(ArialNormal, 10.0, 15.2, 6, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), "GST");
contents.DrawText(ArialNormal, 10.0, 19, 6, TextJustify.Right, DrawStyle.Normal, Color.Black, invoice.GstTotal.ToString("c2"));
contents.SetColorNonStroking(Color.FromArgb(40, 171, 226));
contents.DrawRectangle(14.75, 5, 2.1, 0.8, PaintOp.Fill);
contents.DrawRectangle(16.9, 5, 3, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, 15.2, 5.25, TextJustify.Left, DrawStyle.Normal, Color.White, "TOTAL");
contents.DrawText(ArialBold, 10.0, 18.5, 5.25, TextJustify.Center, DrawStyle.Normal, Color.White, invoice.TotalAmount.ToString("c2"));
}
|