Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mustaddon/arraytopdf
Create PDF from Array (List, DataTable, ...)
https://github.com/mustaddon/arraytopdf
array converter dataset datatable dictionary dotnet list pdf
Last synced: 21 days ago
JSON representation
Create PDF from Array (List, DataTable, ...)
- Host: GitHub
- URL: https://github.com/mustaddon/arraytopdf
- Owner: mustaddon
- License: mit
- Created: 2020-02-06T15:10:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-19T04:41:38.000Z (7 months ago)
- Last Synced: 2024-12-29T08:07:27.588Z (24 days ago)
- Topics: array, converter, dataset, datatable, dictionary, dotnet, list, pdf
- Language: C#
- Homepage:
- Size: 1.16 MB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ArrayToPdf [![NuGet version](https://badge.fury.io/nu/ArrayToPdf.svg?23)](http://badge.fury.io/nu/ArrayToPdf)
Create PDF from Array (List, DataTable, ...)### Example 1: Create with default settings
```C#
using ArrayToPdf;var items = Enumerable.Range(1, 100).Select(x => new
{
Prop1 = $"Text #{x}",
Prop2 = x * 1000,
Prop3 = DateTime.Now.AddDays(-x),
});var pdf = items.ToPdf();
```
Result:
[example1.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example1.pdf)### Example 2: Rename title and columns
```C#
var pdf = items.ToPdf(schema => schema
.Title("Example name")
.ColumnName(m => m.Name.Replace("Prop", "Column #")));
```
Result:
[example2.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example2.pdf)### Example 3: Sort columns
```C#
var pdf = items.ToPdf(schema => schema
.ColumnSort(m => m.Name, desc: true));
```
Result:
[example3.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example3.pdf)### Example 4: Custom column's mapping
```C#
var pdf = items.ToPdf(schema => schema
.PageOrientation(PdfOrientations.Portrait)
.PageMarginLeft(15)
.AddColumn("MyColumnName #1", x => x.Prop1, 30)
.AddColumn("MyColumnName #2", x => $"test:{x.Prop2}")
.AddColumn("MyColumnName #3", x => x.Prop3));
```
Result:
[example4.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example4.pdf)### Example 5: Filter columns
```C#
var pdf = items.ToPdf(schema => schema
.ColumnFilter(m => m.Name != "Prop2"));
```
Result:
[example5.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example5.pdf)### Example 6: Create from DataTable
```C#
var table = new DataTable("Example Table");table.Columns.Add("Column #1", typeof(string));
table.Columns.Add("Column #2", typeof(int));
table.Columns.Add("Column #3", typeof(DateTime));for (var x = 1; x <= 100; x++)
table.Rows.Add($"Text #{x}", x * 1000, DateTime.Now.AddDays(-x));var pdf = table.ToPdf();
```
Result:
[example6.pdf](https://github.com/mustaddon/ArrayToPdf/raw/master/Examples/example6.pdf)[Example.ConsoleApp](https://github.com/mustaddon/ArrayToPdf/tree/master/Examples/Example.ConsoleApp/Program.cs)