How to generate PDF with Multilevel list with hierarchical numbering in C# application

Peter The Batman 1 Reputation point
2022-03-15T23:20:55.49+00:00

Hi, I am new to C#, I am creating a small application, and I need to generate some PDF reports from C# application programmatically. Most of the reports will be Word-like multilevel lists with hierarchical numbering (these numbers have to be calculated automatically). And I want that the levels have indent from the left. I tried several PDF libraries, but none of them can calculate hierarchical numbering. Maybe someone could tell me some library, or how to do it without a library?

I mean something like this:
183409-image.png

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,649 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,417 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,731 Reputation points
    2022-03-18T16:27:54.763+00:00

    PDF is graphics language, not reporting language. maybe you want a reports toolkit that supports pdf output.

    to your question. you would write code to handle the indenting and numbering, similar to the logic you would use with Console.Write()

    0 comments No comments

  2. Castorix31 83,206 Reputation points
    2022-03-18T19:12:57.617+00:00

    or how to do it without a library?

    Just use :

    PrintDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF";
    PrintDocument.PrinterSettings.PrintToFile = true;
    PrintDocument.PrinterSettings.PrintFileName = "your_pdf_filename"";

    and you can draw/write anything in PrintPageEventHandler which will be saved into the .pdf file

    0 comments No comments