0

Can anyone tell me how to use styles with PdfSharpCore? I have a lot of troubles with jsreport running on OpenShift so I wanted to try PdfSharpCore but I am not able to find how to use css. With jsreport is easy, I place my css between <style> </style> and simply add it to the html.

style example: <style>.flex-box { display: flex; flex-flow: row; } .ln-title { font-size: 15px; }</style>

For PdfSharpCore, all I found was var font = new XFont("Arial", 20, XFontStyle.Bold); var textColor = XBrushes.Black; and this is not even what I need/want to achieve...

p.s. feel free to suggest some other free libraries which will work with OpenShift.

Thanks

sosNiLa
  • 289
  • 6
  • 18
  • this example can probably help you: [example](https://github.com/ststeiger/PdfSharpCore/blob/master/docs/MigraDocCore/samples/Invoice.md) – lordvlad30 Feb 22 '23 at 14:41
  • thanks lordvlad30, but I had in mind to use css classes, something like – sosNiLa Feb 23 '23 at 08:39
  • this can maybe help: [other question](https://stackoverflow.com/questions/31261981/create-pdf-from-html-snippet-using-pdfsharp-having-external-css-classes-included) – lordvlad30 Feb 23 '23 at 11:05

1 Answers1

0

This library might be better to use stylesheets with. It is similar to PdfSharpCore, but renders HTML and CSS, making it better to use with stylesheets. I used it and it is about 3 lines to render HTML.

My recommendation would be to either read the HTML to a string from a file or use a verbatim string and replace every double quotation inside the string with two double quotations (and remove every newline). I did this by using the find and replace tool.

Chase C
  • 86
  • 5