PdfSharpCore - how to use styles

460 Views Asked by At

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

1

There are 1 best solutions below

0
Chase C On

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.