Autor: Bodoconsult EDV-Dienstleistungen GmbH, Robert Leisner
https://www.nuget.org/packages/Bodoconsult.Core.Text.Pdf/
https://github.com/RobertLeisner/Bodoconsult.Core.Text.Pdf
Bodoconsult.Core.Text.Pdf is an enhancement for Bodoconsult.Core.Text, a simple tool to generate structured text documents in a C### project. It enables export of a structured text to a PDF file.
We use Bodoconsult.Core.Text and Bodoconsult.Core.Text.Pdf for creating unit test logfiles intended for presentation to auditors. Another usage at Bodoconsult is creating an automated documentation for an app based on unit tests.
The source code contain NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.
var st = new StructuredText();
st.AddHeader1("Überschrift 1");
st.AddParagraph(TestHelper.Masstext1);
var code = FileHelper.GetTextResource("code1.txt");
st.AddCode(code);
st.AddParagraph(TestHelper.Masstext1);
st.AddDefinitionListLine("Left1", "Right1");
st.AddDefinitionListLine("Left2", "Right2");
st.AddDefinitionListLine("Left3", "Right3");
st.AddDefinitionListLine("Left4", "Right4");
st.AddParagraph(TestHelper.Masstext1);
st.AddTable("Tabelle", TestHelper.GetDataTable());
st.AddHeader1("Überschrift 2");
st.AddDefinitionListLine("Left1", "Right1");
st.AddDefinitionListLine("Left2", "Right2");
st.AddDefinitionListLine("Left3", "Right3");
st.AddDefinitionListLine("Left4", "Right4");
var f = new PdfTextFormatter
{
Title = "Testreport",
StructuredText = st,
DateString = $"Date created: {DateTime.Now:G}",
Author = "Testautor"
};
f.GetFormattedText();
f.SaveAsFile(fileName);
var sr = new StructuredText();
sr.AddHeader1("Überschrift 1 '& &&&' ");
sr.AddParagraph(MassText, "CssTestFixture");
sr.AddDefinitionListLine("Def1", "Value1");
sr.AddDefinitionListLine("Definition 2", "Value1234");
sr.AddDefinitionListLine("Defini 3", "Value234556666");
sr.AddParagraph("");
sr.AddParagraph(FormattedMasstext,
"CssTestFixture");
sr.AddCode(MassText, "CssTestFixture");
sr.AddParagraph(MassText);
sr.AddListItem("Bahnhof");
sr.AddListItem("HauptBahnhof");
sr.AddListItem("SüdBahnhof");
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
var f = new HtmlTextFormatter { StructuredText = sr };
f.GetFormattedText();
f.SaveAsFile(fileName);
var sr = new StructuredText();
sr.AddHeader1("Überschrift 'Databanka'");
sr.AddParagraph(MassText);
sr.AddDefinitionListLine("Def1", "Value1");
sr.AddDefinitionListLine("Definition 2", "Value1234");
sr.AddDefinitionListLine("Defini 3", "Value234556666");
sr.AddParagraph("");
sr.AddParagraph(MassText);
sr.AddListItem("Bahnhof");
sr.AddListItem("HauptBahnhof");
sr.AddListItem("SüdBahnhof");
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader2("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
var f = new HtmlTextFormatter
{
StructuredText = sr,
Template = "<<<Start>>>{0}<<<Ende>>>",
AddTableOfContent = true
};
var result = f.GetFormattedText();
f.SaveAsFile(fileName);
var sr = new StructuredText(); sr.AddHeader1("Überschrift 1"); sr.AddParagraph(MassText); sr.AddDefinitionListLine("Def1", "Value1"); sr.AddDefinitionListLine("Definition 2", "Value1234"); sr.AddDefinitionListLine("Defini 3", "Value234556666"); sr.AddParagraph(""); sr.AddParagraph(MassText);
sr.AddListItem("Bahnhof");
sr.AddListItem("HauptBahnhof");
sr.AddListItem("SüdBahnhof");
sr.AddHeader1("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 2");
sr.AddParagraph(MassText);
sr.AddHeader1("Überschrift 1");
sr.AddParagraph(MassText);
sr.AddParagraph(MassText);
var f = new PlainTextFormatter { StructuredText = sr };
var result = f.GetFormattedText();
f.SaveAsFile(fileName);
PdfSharp and Migradoc do not support stylesets by default- Same for PdfSharp.MigraDoc.netstandard 1.3.1. MigraDoc supports styles for styling PDF files.
Bodoconsult.Core.Pdf added styleset functionality. A styleset is defined as a list of MigraDoc styles. Therefore you can use all style settings supported by MigraDoc styles.
With exception of the Normal style all styles defined in a styleset are injected as new styles to the MigraDoc PDF document.
The Normal style exists in a MigraDoc PDF document by default. The Normal style from the styleset therefore has to cloned to the MigraDoc PDF document. It may happen that not all properties are cloned correctly.
Bodoconsult (http://www.bodoconsult.de) is a Munich based software company.
Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.
Copyright (c) 2015 - 2020 Bodoconsult EDV-Dienstleistungen GmbH, Vaterstetten (Germany)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
https://licenses.nuget.org/MIT
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
https://www.nuget.org/packages/PdfSharp.MigraDoc.netstandard/1.3.1/license
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.