swxben / crispin Goto Github PK
View Code? Open in Web Editor NEWReporting library, using Razor templates to generate HTML, Excel and PDF reports
Home Page: http://crispin.readthedocs.org/en/latest/
Reporting library, using Razor templates to generate HTML, Excel and PDF reports
Home Page: http://crispin.readthedocs.org/en/latest/
If you have an a
tag inside a htmlBlock
, it doesn't get converted to a link in the resulting PDF using PdfReportConverter
and XrptToXslFo.xslt
. Dumping out the href into the report works but that is probably just Adobe Reader finding URLs and marking them up. I'm not sure how/if XSL-FO supports links natively.
Links don't work in the HtmlReportConverter
either, this is detailed in issue #5.
Using normal HTML <ul><li>
tags.
Use the normal HTML <dl><dt><dd>
elements.
If you have an a
tag inside a htmlBlock
, it doesn't get converted to a link in the resulting HTML when processed by the HtmlReportConverter
. It will need to be picked up in XrptToHtml.xslt
.
There is a related issue with links not working in PDFs (#4).
Using normal HTML <ol><li>
tags. Should also support the type
attribute to change the marker type.
Byte order marks at the start of input strings are killing the calls to xml.LoadXml
in the converters.
The correct way to handle this would be to use a memory stream with the correct encoding:
xml.Load(new MemoryStream(Encoding.UTF8.GetBytes(xrpt)));
But this may bork on non-UTF8 inputs. The easiest way is to strip the BOM:
xrpt = xrpt.Trim().Trim(new char[]{'\uFEFF','\u200B'});
Will require rebuilding the FOP DLL. I tried upgrading it and things stopped working. Possibly related, possibly not, I didn't have time to investigate fully.
Given this report:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE report [
<!ENTITY nbsp " ">
<!ENTITY ldquo "“">
<!ENTITY lsquo "‘">
<!ENTITY rdquo "”">
<!ENTITY rsquo "’">
<!ENTITY quot """>
]>
<report>
<title>Table background test</title>
<content>
<pageSequence orientation="portrait">
<htmlBlock>
<table>
<col width="50%" />
<col width="50%" />
<tbody>
<tr>
<td background-color="#F2385A"> </td>
<td background-color="#F5A503"> </td>
</tr>
</tbody>
</table>
<br />
</htmlBlock>
</pageSequence>
</content>
</report>
Generating a PDF produces a bar with the correct background colours:
But the HTML export of the same report produces a blank report. The problem seems to be that the style
attribute generated by the XSL transform (in XrptToHtml.xslt
) is messed up:
<table cellpadding="0" cellspacing="0" class="layoutTable">
<col width="50%" />
<col width="50%" />
<tbody>
<tr>
<td style="
 background-color: "#F2385A";
 "> </td>
<td style="
 background-color: "#F5A503";
 "> </td>
</tr>
</tbody>
</table>
A reporting service (IReportingService
, ReportingService
) which initially allows saving a report to a temporary PDF then opening it via Process.Start
.
This can happen when the razor template has statements preceding the <?xml
tag. Should be fixed by doing a string.Trim()
on the incoming template.
<htmlBlock>
<table>
<col width="50%"/>
<col width="50%"/>
<tbody>
<tr>
<td> </td>
<td align="right">
<table type="DataGrid">
<col width="10%"/>
<col width="10%"/>
<tbody><tr><td>ONE</td><td>TWO</td></tr></tbody>
</table>
</td>
</tr>
</tbody>
</table>
</htmlBlock>
I would expect the nested table to be aligned to the right of the containing cell, however it is left aligned.
Try to allow any XHTML to be converted/parsed.
There are free tools that makes from a HTML XHTML.
What you should (could) do:
@* Generator: Template *@
<!ENTITY ldquo "“">
<!ENTITY lsquo "‘">
<!ENTITY rdquo "”">
<!ENTITY rsquo "’">
<!ENTITY quot """>
]>
So if you modify the structure a bit, it could be a HTML to XHTML to PDF/CSV converter.
Don't fully understand why you need to generate templates into CS. Razor can do this on the fly, precompiled code can be cached (f.e. static variable inside class)...
Examples are cool, documentation would be even better.
There should be a DTD for the XRPT XML format. Documentation of the format should be created as part of the DTD.
ReadAsPdf()
to return byte[]
Left padding a table causes the table to just be pushed right, so the table still has the same width. Example XRPT that shows this:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE report [
<!ENTITY nbsp " ">
<!ENTITY ldquo "“">
<!ENTITY lsquo "‘">
<!ENTITY rdquo "”">
<!ENTITY rsquo "’">
<!ENTITY quot """>
]>
<report>
<title>Left padded table</title>
<content>
<pageSequence orientation="portrait">
<htmlBlock>
<h1>Left padded table</h1>
</htmlBlock>
<contentBlock padding-left="1.1cm">
<table>
<col width="50%" />
<col width="50%" />
<thead>
<tr>
<th align="left">Name</th>
<th align="right">ID</th>
</tr>
</thead>
<tbody>
<tr><td>Ben</td> <td align="right">123</td></tr>
<tr><td>Justine</td> <td align="right">456</td></tr>
<tr><td>Ann</td> <td align="right">445</td></tr>
</tbody>
</table>
</contentBlock>
</pageSequence>
</content>
</report>
This results in the ID column being cut off on the right-hand side of the page. This is caused by the calculation used to determine column widths in XrptToXslFo.xslt
- search for <xsl:template match="col">
. It uses the page width, adjusting down for nested table padding, but doesn't take into consideration padding values specified in other containing elements.
Write the report to a temporary file and Process.Start()
it
I Can't Believe It's Not System.Web
A minimalist copy of things found in System.Web that are needed to fool RazorGenerator.Templating into letting us use Razor tricks like helpers and IHtmlString. Implemented as a new NuGet package that can be both discreetly and discretely dropped in.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.