feat: add AccentBlue palette, reduced margins, DrawFooter with branding support
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ using Syncfusion.Drawing;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.Pdf.Graphics;
|
||||
using Syncfusion.Pdf.Grid;
|
||||
using Syncfusion.Pdf.Interactive;
|
||||
|
||||
namespace CertReports.Syncfusion.Helpers;
|
||||
|
||||
@@ -22,6 +23,16 @@ public static class PdfTheme
|
||||
public static readonly Color NegativeValue = Color.FromArgb(255, 220, 53, 69); // rosso
|
||||
public static readonly Color SectionTitle = Color.FromArgb(255, 46, 80, 144);
|
||||
|
||||
// Nuovi colori stile "Ibrido elegante"
|
||||
public static readonly Color AccentBlue = Color.FromArgb(255, 21, 101, 192); // #1565C0
|
||||
public static readonly Color NegativeRed = Color.FromArgb(255, 204, 0, 0); // #CC0000
|
||||
public static readonly Color PositiveGreen = Color.FromArgb(255, 46, 125, 50); // #2E7D32
|
||||
public static readonly Color FooterText = Color.FromArgb(255, 102, 102, 102); // #666666
|
||||
public static readonly Color SeparatorLine = Color.FromArgb(255, 221, 221, 221); // #DDDDDD
|
||||
public static readonly Color TableBorder = Color.FromArgb(255, 187, 187, 187); // #BBBBBB
|
||||
public static readonly Color TableAltRow = Color.FromArgb(255, 247, 249, 252); // #F7F9FC
|
||||
public static readonly Color TableHeaderBg = Color.FromArgb(255, 21, 101, 192); // #1565C0
|
||||
|
||||
// ─── Font ──────────────────────────────────────────────────────────
|
||||
private static readonly PdfStandardFont _fontRegular = new(PdfFontFamily.Helvetica, 8f);
|
||||
private static readonly PdfStandardFont _fontBold = new(PdfFontFamily.Helvetica, 8f, PdfFontStyle.Bold);
|
||||
@@ -31,6 +42,11 @@ public static class PdfTheme
|
||||
private static readonly PdfStandardFont _fontSectionTitle = new(PdfFontFamily.Helvetica, 10f, PdfFontStyle.Bold);
|
||||
private static readonly PdfStandardFont _fontHeader = new(PdfFontFamily.Helvetica, 7f, PdfFontStyle.Bold);
|
||||
|
||||
private static readonly PdfStandardFont _fontFooter = new(PdfFontFamily.Helvetica, 7f);
|
||||
private static readonly PdfStandardFont _fontFooterBold = new(PdfFontFamily.Helvetica, 7f, PdfFontStyle.Bold);
|
||||
private static readonly PdfStandardFont _fontTable = new(PdfFontFamily.Helvetica, 7.5f);
|
||||
private static readonly PdfStandardFont _fontTableBold = new(PdfFontFamily.Helvetica, 7.5f, PdfFontStyle.Bold);
|
||||
|
||||
public static PdfFont Regular => _fontRegular;
|
||||
public static PdfFont Bold => _fontBold;
|
||||
public static PdfFont Small => _fontSmall;
|
||||
@@ -38,12 +54,17 @@ public static class PdfTheme
|
||||
public static PdfFont Title => _fontTitle;
|
||||
public static PdfFont SectionTitleFont => _fontSectionTitle;
|
||||
public static PdfFont Header => _fontHeader;
|
||||
public static PdfFont Footer => _fontFooter;
|
||||
public static PdfFont FooterBold => _fontFooterBold;
|
||||
public static PdfFont TableFont => _fontTable;
|
||||
public static PdfFont TableBold => _fontTableBold;
|
||||
|
||||
// ─── Margini & Layout ──────────────────────────────────────────────
|
||||
public const float PageMargin = 40f;
|
||||
public const float RowHeight = 18f;
|
||||
public const float HeaderRowHeight = 22f;
|
||||
public const float CellPadding = 4f;
|
||||
public const float PageMargin = 36f; // era 40f
|
||||
public const float RowHeight = 14f; // era 18f — KV pairs sezione Analisi
|
||||
public const float HeaderRowHeight = 18f; // era 22f — header sezioni
|
||||
public const float CellPadding = 4f;
|
||||
public const float FooterHeight = 28f; // spazio riservato footer in fondo alla pagina
|
||||
|
||||
// ─── Brushes ───────────────────────────────────────────────────────
|
||||
public static PdfBrush HeaderBrush => new PdfSolidBrush(HeaderBackground);
|
||||
@@ -54,6 +75,15 @@ public static class PdfTheme
|
||||
public static PdfBrush PositiveBrush => new PdfSolidBrush(PositiveValue);
|
||||
public static PdfBrush NegativeBrush => new PdfSolidBrush(NegativeValue);
|
||||
public static PdfPen BorderPen => new PdfPen(BorderColor, 0.5f);
|
||||
public static PdfBrush AccentBlueBrush => new PdfSolidBrush(AccentBlue);
|
||||
public static PdfBrush NegativeBrush2 => new PdfSolidBrush(NegativeRed);
|
||||
public static PdfBrush PositiveBrush2 => new PdfSolidBrush(PositiveGreen);
|
||||
public static PdfBrush FooterTextBrush => new PdfSolidBrush(FooterText);
|
||||
public static PdfBrush TableAltRowBrush => new PdfSolidBrush(TableAltRow);
|
||||
public static PdfBrush TableHeaderBrush => new PdfSolidBrush(TableHeaderBg);
|
||||
public static PdfPen SeparatorPen => new PdfPen(SeparatorLine, 0.5f);
|
||||
public static PdfPen TableBorderPen => new PdfPen(TableBorder, 0.5f);
|
||||
public static PdfPen AccentBluePen => new PdfPen(AccentBlue, 2.5f);
|
||||
|
||||
// ─── Utility ───────────────────────────────────────────────────────
|
||||
public static PdfBrush ValueBrush(decimal? value)
|
||||
@@ -123,4 +153,58 @@ public static class PdfTheme
|
||||
for (int c = 0; c < grid.Rows[r].Cells.Count; c++)
|
||||
grid.Rows[r].Cells[c].Style.Borders = borders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disegna il footer in fondo alla pagina.
|
||||
/// Se showBranding=true: "Powered by [Smart Roots↗]" a sx + numero pagina a dx.
|
||||
/// Se showBranding=false: solo numero pagina centrato.
|
||||
/// </summary>
|
||||
public static void DrawFooter(
|
||||
PdfGraphics g,
|
||||
float pageWidth,
|
||||
float pageHeight,
|
||||
int pageNumber,
|
||||
bool showBranding)
|
||||
{
|
||||
float footerY = pageHeight - FooterHeight + 6f;
|
||||
|
||||
// Linea separatrice
|
||||
g.DrawLine(SeparatorPen, 0, footerY - 4f, pageWidth, footerY - 4f);
|
||||
|
||||
string pageLabel = pageNumber.ToString();
|
||||
|
||||
if (!showBranding)
|
||||
{
|
||||
// Solo numero pagina centrato
|
||||
g.DrawString(pageLabel, Footer, FooterTextBrush,
|
||||
new RectangleF(0, footerY, pageWidth, 12f),
|
||||
new PdfStringFormat(PdfTextAlignment.Center));
|
||||
return;
|
||||
}
|
||||
|
||||
// "Powered by " testo normale
|
||||
const string prefix = "Powered by ";
|
||||
const string linkText = "Smart Roots";
|
||||
const string linkUrl = "https://www.smart-roots.net";
|
||||
|
||||
float prefixWidth = Footer.MeasureString(prefix).Width;
|
||||
|
||||
g.DrawString(prefix, Footer, FooterTextBrush,
|
||||
new RectangleF(0, footerY, prefixWidth + 2f, 12f));
|
||||
|
||||
// "Smart Roots" come hyperlink PDF
|
||||
var webLink = new PdfTextWebLink
|
||||
{
|
||||
Url = linkUrl,
|
||||
Text = linkText,
|
||||
Font = Footer,
|
||||
Brush = AccentBlueBrush,
|
||||
};
|
||||
webLink.DrawTextWebLink(g, new PointF(prefixWidth, footerY));
|
||||
|
||||
// Numero pagina a destra
|
||||
g.DrawString(pageLabel, Footer, FooterTextBrush,
|
||||
new RectangleF(0, footerY, pageWidth, 12f),
|
||||
new PdfStringFormat(PdfTextAlignment.Right));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user