|
// Create a
new PDF document.
PdfDocument
document = new PdfDocument();
// Add a page
to the document.
PdfPage page
= document.Pages.Add();
// Create a
PdfGrid.
PdfGrid
pdfGrid = new PdfGrid();
// Add values
to list
List<object>
data = new List<object>
{
new { NOTA = "Q1120", NOMBRE =
"FEDE", CANTIDAD = "1081" },
new { NOTA = "Q1121", NOMBRE =
"CIRCULO K", CANTIDAD = "1118" },
new { NOTA = "Q1120", NOMBRE =
"CIRCULO K", CANTIDAD = "249" },
new { NOTA = "Q1121", NOMBRE =
"QUÍMICA VARGAS", CANTIDAD = "1118" },
new { NOTA = "Q1122", NOMBRE =
"QUÍMICA VARGAS", CANTIDAD = "249" },
new { NOTA = "Q1119", NOMBRE =
"BOLT-DIDI", CANTIDAD = "30" },
new { NOTA = "", NOMBRE =
"LIMPIECITO", CANTIDAD = "182" }
};
// Assign
data source.
pdfGrid.DataSource
= data;
// Set
alignment for the first column (NOTA) to left
pdfGrid.Columns[0].Format
= new PdfStringFormat
{
Alignment = PdfTextAlignment.Left
};
// Set
alignment for the second column (NOMBRE) to left
pdfGrid.Columns[1].Format
= new PdfStringFormat
{
Alignment = PdfTextAlignment.Left
};
//
Optionally, align the third column (CANTIDAD) to right
pdfGrid.Columns[2].Format
= new PdfStringFormat
{
Alignment = PdfTextAlignment.Right
};
// Draw the
grid on the page
pdfGrid.Draw(page,
new Syncfusion.Drawing.PointF(0, 0));
// Save the
document
using
(FileStream outputFileStream = new FileStream("Output.pdf",
FileMode.Create, FileAccess.Write))
{
document.Save(outputFileStream);
}
// Close the
document
document.Close(true);
|