SoFunction
Updated on 2025-03-07

C# Method to generate pdf report using doggleReport

This article describes the method of using doggleReport to generate pdf reports in C#. Share it for your reference, as follows:

1. Install nuget

-install package DoddleReport
-install package 

2. Example code

static void Main(string[] args)
{
 var query = GetAll();
 var report = new Report(());
  = "Graduate Student Report";
  = "sample header";
  = "sample footer";
  = (@"
Report Generated: {0}
Total Students: {1}", , 100);
  = true;
 ["Id"].Hidden = true;
 var stream = new MemoryStream();
 var writer = new PdfReportWriter();
 (report, stream);
 const string path = "C:\\test";
 if (!(path))
 {
  (path);
 }
 ((path+"/studentReport_{0}.pdf",("dd-MM-yyyy_HH-mm-ss")), ());
 ("done");
}
public class Student
{
 public int Id { get; set; }
 public string Name { get; set; }
 public bool IsPass { get; set; }
 public int Score { get; set; }
 public DateTime GraduateAt { get; set; }
}
public static List<Student> GetAll()
{
 var rand = new Random();
 return (1, 1000)
  .Select(i => new Student
  {
   Id = i,
   Name = "Product " + i,
   Score = (100),
   GraduateAt = 
  })
  .ToList();
}

3. View the results in the C:\test folder

For more information about C# related content, please check out the topic of this site:Summary of common techniques for C# file operation》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《C# data structure and algorithm tutorial》、《Introduction to C# object-oriented programming tutorial"and"Summary of thread usage techniques for C# programming

I hope this article will be helpful to everyone's C# programming.