Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{
// Create a new PdfCompressionOptions object
PdfCompressionOptions options = new PdfCompressionOptions();
//Enable the compress image
options.CompressImages = true;
//Set the image quality
options.ImageQuality = 50;
// Compress the PDF document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath
{
// Create a new PdfCompressionOptions object
PdfCompressionOptions options = new PdfCompressionOptions();
//Enable the compress image
options.CompressImages = true;
//Set the image quality
options.ImageQuality = 50;
// Compress the PDF document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@
// Create a new PDF document
using (PdfDocument document = new PdfDocument())
{
//Add a page to the document
// Add a new page to the PDF document
PdfPage page = document.Pages.Add();
// Create a PdfGrid
// Create a PdfGrid to display tabular data
PdfGrid pdfGrid = new PdfGrid();
// Add values to the list
List<object> data = new List<object>
{
new { ID = "E01", Name = "Clay" },
new { ID = "E02", Name = "Thomas" },
new { ID = "E03", Name = "John" }
};
// Assign the data source to the grid
// Prepare sample data for the grid
object data = new List<object>
{
new { ID = "E01", Name = "Clay", Department = "HR" },
new { ID = "E02", Name = "Thomas", Department = "Finance" },
new { ID = "E03", Name = "John", Department = "IT" },
new { ID = "E04", Name = "Emma", Department = "Marketing" },
new { ID = "E05", Name = "Sophia", Department = "Operations" }
};
// Assign the data source to the grid (auto-generates a header row)
pdfGrid.DataSource = data;
// Draw the grid on the PDF page
pdfGrid.Draw(page, new PointF(10, 10));
//Apply built-in table style
pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent6);
// Apply padding and font style to body cells
pdfGrid.Style.CellPadding = new PdfPaddings(10, 6, 10, 6);
// Draw the grid on the PDF page at specified position (with margin)
pdfGrid.Draw(page, new PointF(20, 40));
// Save the PDF document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ Step 4: **Add a table to the PDF**: Use the following code in **Program.cs** to
// Create a new PDF document
using (PdfDocument document = new PdfDocument())
{
//Add a page to the document
// Add a new page to the PDF document
PdfPage page = document.Pages.Add();
// Create a PdfGrid
// Create a PdfGrid to display tabular data
PdfGrid pdfGrid = new PdfGrid();
// Add values to the list
List<object> data = new List<object>
{
new { ID = "E01", Name = "Clay" },
new { ID = "E02", Name = "Thomas" },
new { ID = "E03", Name = "John" }
};
// Assign the data source to the grid
// Prepare sample data for the grid
object data = new List<object>
{
new { ID = "E01", Name = "Clay", Department = "HR" },
new { ID = "E02", Name = "Thomas", Department = "Finance" },
new { ID = "E03", Name = "John", Department = "IT" },
new { ID = "E04", Name = "Emma", Department = "Marketing" },
new { ID = "E05", Name = "Sophia", Department = "Operations" }
};
// Assign the data source to the grid (auto-generates a header row)
pdfGrid.DataSource = data;
// Draw the grid on the PDF page
pdfGrid.Draw(page, new PointF(10, 10));
//Apply built-in table style
pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent6);
// Apply padding and font style to body cells
pdfGrid.Style.CellPadding = new PdfPaddings(10, 6, 10, 6);
// Draw the grid on the PDF page at specified position (with margin)
pdfGrid.Draw(page, new PointF(20, 40));
// Save the PDF document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
Expand Down
Loading