Skip to content

Commit 0eca904

Browse files
committed
#177 Visual regression test for Latex rendering support.
1 parent 3b02928 commit 0eca904

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed
Binary file not shown.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<html>
2+
<head>
3+
<style>
4+
@font-face {
5+
src: url(fonts/Karla-Bold.ttf);
6+
font-family: 'MyFont';
7+
font-weight: normal;
8+
}
9+
@page {
10+
size: 10cm 30cm;
11+
margin: 0;
12+
}
13+
body {
14+
margin: 0;
15+
font-family: 'MyFont';
16+
font-size: 15px;
17+
}
18+
latex {
19+
display: block;
20+
width: 100%;
21+
margin: 2px;
22+
padding: 5px;
23+
page-break-inside: avoid;
24+
}
25+
math {
26+
font-family: 'MyFont';
27+
}
28+
</style>
29+
</head>
30+
<body>
31+
32+
<latex><![CDATA[
33+
Simple list:
34+
\begin{itemize}
35+
\item First item
36+
\item Second item
37+
\end{itemize}
38+
]]>
39+
</latex>
40+
41+
<latex><![CDATA[
42+
Here is a simple table without column lines:
43+
44+
\begin{tabular}{ l c r }
45+
1 & 2 & 3 \\
46+
4 & 5 & 6 \\
47+
7 & 8 & 9 \\
48+
\end{tabular}
49+
50+
In this table you get column lines:
51+
52+
\begin{tabular}{ l | c | r }
53+
1 & 2 & 3 \\
54+
4 & 5 & 6 \\
55+
7 & 8 & 9 \\
56+
\end{tabular}
57+
58+
And of course you can get both:
59+
\begin{tabular}{ l | c | r }
60+
\hline
61+
1 & 2 & 3 \\
62+
4 & 5 & 6 \\
63+
7 & 8 & 9 \\
64+
\hline
65+
\end{tabular}
66+
]]>
67+
</latex>
68+
69+
<latex><![CDATA[
70+
And even fancier:
71+
\begin{center}
72+
\begin{tabular}{ | l | c | r | }
73+
\hline
74+
1 & 2 & 3 \\ \hline
75+
4 & 5 & 6 \\ \hline
76+
7 & 8 & 9 \\
77+
\hline
78+
\end{tabular}
79+
\end{center}
80+
81+
The full possibilities of $L^AT_EX$:
82+
83+
\begin{tabular}{|r|l|}
84+
\hline
85+
7C0 & hexadecimal \\
86+
3700 & octal \\
87+
11111000000 & binary \\
88+
\hline \hline
89+
1984 & decimal \\
90+
\hline
91+
\end{tabular}
92+
]]>
93+
</latex>
94+
95+
<latex><![CDATA[
96+
Math:
97+
$ \frac{x+1}{3y} $
98+
$ x^{2^{y-z}} $
99+
]]>
100+
</latex>
101+
102+
</body>
103+
</html>

openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.Ignore;
99
import org.junit.Test;
1010

11+
import com.openhtmltopdf.latexsupport.LaTeXDOMMutator;
1112
import com.openhtmltopdf.mathmlsupport.MathMLDrawer;
1213
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
1314
import com.openhtmltopdf.svgsupport.BatikSVGDrawer;
@@ -774,6 +775,18 @@ public void testReplacedSizingMathMl() throws IOException {
774775
}));
775776
}
776777

778+
/**
779+
* Tests the Latex support plugin including maths which are interpreted with
780+
* the MathML plugin.
781+
*/
782+
@Test
783+
public void testReplacedPluginLatex() throws IOException {
784+
assertTrue(vt.runTest("replaced-plugin-latex", (builder) -> {
785+
builder.addDOMMutator(LaTeXDOMMutator.INSTANCE);
786+
builder.useMathMLDrawer(new MathMLDrawer());
787+
}));
788+
}
789+
777790
// TODO:
778791
// + Elements that appear just on generated overflow pages.
779792
// + content property (page counters, etc)

openhtmltopdf-latex-support/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<packaging>jar</packaging>
1515

1616
<name>Openhtmltopdf Latex Math Support</name>
17-
<description>Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact supports drawing MathML graphics on to PDFs using JEuclid.</description>
17+
<description>Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact supports rendering Latex markup (including math) on to PDFs using SnuggleTex.</description>
1818

1919
<licenses>
2020
<license>

0 commit comments

Comments
 (0)