private void CreatePdfBox(PdfContentByte content, Configuration.PrintTemplateContentRow row, bool allowFill)
{
if (row.IsFillColorNull() && row.IsOutlineWidthNull() && row.IsOutlineColorNull())
{
return;
}
bool hasFill = false;
bool hasStroke = false;
content.SetLineWidth((1 / PixelsPerInch) * PointsPerInch);
if (!row.IsFillColorNull() && allowFill)
{
System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml(row.FillColor);
content.SetRGBColorFill(c.R, c.G, c.B);
hasFill = true;
}
if (!row.IsOutlineWidthNull())
{
content.SetLineWidth((Convert.ToSingle(row.OutlineWidth) / PixelsPerInch) * PointsPerInch);
hasStroke = true;
}
if (!row.IsOutlineColorNull())
{
System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml(row.OutlineColor);
content.SetRGBColorStroke(c.R, c.G, c.B);
hasStroke = true;
}
float originX = Convert.ToSingle(row.OriginX) * PointsPerInch;
float originY = Convert.ToSingle(row.OriginY) * PointsPerInch;
float width = Convert.ToSingle(row.Width) * PointsPerInch;
float height = Convert.ToSingle(row.Height) * PointsPerInch;
if (hasFill)
{
content.Rectangle(originX, originY, width, height);
content.Fill();
}
if (hasStroke)
{
content.Rectangle(originX, originY, width, height);
content.Stroke();
}
}