From b7a51f10be9c1529ad75ae55f67fbc2243f9f2e7 Mon Sep 17 00:00:00 2001 From: DenisPitcher Date: Sat, 6 Aug 2016 14:45:41 +0200 Subject: [PATCH 1/2] Create initial PDFGeneration documentation --- Documentation/PDFGeneration.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Documentation/PDFGeneration.md diff --git a/Documentation/PDFGeneration.md b/Documentation/PDFGeneration.md new file mode 100644 index 000000000..c6d6bbbb2 --- /dev/null +++ b/Documentation/PDFGeneration.md @@ -0,0 +1,2 @@ +Generate PDF + From 74af9c04e631d5361480a0991e39ce28f89fc452 Mon Sep 17 00:00:00 2001 From: DenisPitcher Date: Sat, 6 Aug 2016 15:29:34 +0200 Subject: [PATCH 2/2] Adding CSS styling example --- Documentation/PDFGeneration.md | 49 +++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/Documentation/PDFGeneration.md b/Documentation/PDFGeneration.md index c6d6bbbb2..d3ae9e003 100644 --- a/Documentation/PDFGeneration.md +++ b/Documentation/PDFGeneration.md @@ -1,2 +1,49 @@ -Generate PDF +**Generate PDF** +IN order to get started, add the following snippet in your main method: + +``` +class Program +{ + private static void Main(string[] args) + { + string html = "

Hello World

This is html rendered text

"; + PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.A4); + pdf.Save("document.pdf"); + } +} +``` + +**Applying CSS** + +Adjust your HTML to include a class definition to customize html within your text. + +``` +string html = "

Hello World

This is html rendered text with css styling in blue

"; +``` + +Add a new css definition +``` +string css = ".blue { color: blue; } "; +``` + +Adjust your GeneratePdf parameters to include style sheet parsing and a margin setting matching the default of 20 +``` +PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.A4, 20, PdfGenerator.ParseStyleSheet(css)); +``` + +Your code should now look like this +``` +class Program +{ + private static void Main(string[] args) + { + string html = "

Hello World

This is html rendered text with css styling in blue

"; + string css = ".blue { color: blue; }"; + PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.A4, 20, PdfGenerator.ParseStyleSheet(css)); + pdf.Save("document.pdf"); + } +} +``` + +If you run this code you should now see your sample with some styled text \ No newline at end of file