Reputation: 6178
I am try to create a OMR sheet. For that need a design like below. I made in html & css.
but in iTextSharp it does not work as html in browser.
<td style="border-width:0 2px 0 4px; border-style:solid; border-color:white; padding:0 20px;">
<div style="height:17px; width:25px; padding:2px; float:left;">1</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">A</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">B</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">C</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">D</div>
</td>
border & border-radius don't work
How can I solve that any idea. Thanks
Upvotes: 1
Views: 979
Reputation: 77528
I tried this code:
public static final String SRC = "circle.html";
public static final String DEST = "circle.pdf";
public static void main(String[] args) throws IOException {
LicenseKey.loadLicenseFile(System.getenv("ITEXT7_LICENSEKEY") + "/itextkey-html2pdf_typography.xml");
Alignment app = new Alignment();
app.createPdf(SRC, DEST);
}
public void createPdf(String src, String dest) throws IOException {
HtmlConverter.convertToPdf(new File(src), new File(dest));
}
The file circle.pdf
looks like this (note that I removed white
as border color, or the border would have been invisible):
<table>
<tr>
<td style="border-width:0 2px 0 4px; border-style:solid; padding:0 20px;" colspan="3">
<div style="height:17px; width:25px; padding:2px; float:left;">1</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">A</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">B</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">C</div>
<div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">D</div>
</td>
</tr>
</table>
The result looks like this:
I'd say this looks more or less OK, but:
ITagWorker
to draw real circles around the content instead of working with rounded corners, or, if you have a limited set of characters that require circles, use a font of which the glyphs already come with circles.Upvotes: 2