1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| using(PdfDocument document = new PdfDocument())
{
using(PdfPage page = document.AddPage())
{
// Get an XGraphics object for drawing
using(XGraphics gfx = XGraphics.FromPdfPage(page))
{
// Create a font
XFont font1 = new XFont("Verdana", 20, XFontStyle.Underline);
XFont fElement = new XFont("Verdana", 8, XFontStyle.Bold);
gfx.DrawString(Titre, fElement, XBrushes.Black, new XRect(100, 180 + c, 11, 11), XStringFormats.Center);
gfx.DrawString(hidCode, fElement, XBrushes.Black, new XRect(410, 180 + c, 11, 11), XStringFormats.Center);
string pathPdf = AppDomain.CurrentDomain.BaseDirectory + @"PDFFiles\" + hidCode + ".pdf";
document.Save(@pathPdf);
}
}
} |
Partager