@@ -26,20 +26,20 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.tidy.Tidy;
|
||||
|
||||
public class ApacheFOPConvertHTMLTest {
|
||||
private String inputFile = "src/test/resources/hello.html";
|
||||
private String inputFile = "src/test/resources/input.html";
|
||||
private String style = "src/test/resources/xhtml2fo.xsl";
|
||||
private String style1 = "src/test/resources/docbook-xsl/fo/docbook.xsl";
|
||||
private String output = "src/test/resources/hello.pdf";
|
||||
private String output1 = "src/test/resources/hello1.pdf";
|
||||
private String output2 = "src/test/resources/hello2.pdf";
|
||||
private String foFile = "src/test/resources/hello.fo";
|
||||
private String xmlFile = "src/test/resources/hello.xml";
|
||||
private String output_jtidy = "src/test/resources/output_jtidy.pdf";
|
||||
private String output_html2fo = "src/test/resources/output_html2fo.pdf";
|
||||
private String output_herold = "src/test/resources/output_herold.pdf";
|
||||
private String foFile = "src/test/resources/input.fo";
|
||||
private String xmlFile = "src/test/resources/input.xml";
|
||||
|
||||
@Test
|
||||
public void whenTransformHTMLToPDFUsingJTidy_thenCorrect() throws Exception {
|
||||
final Document xhtml = fromHTMLToXHTML();
|
||||
final Document fo = fromXHTMLToFO(xhtml);
|
||||
fromFODocumentToPDF(fo, output);
|
||||
fromFODocumentToPDF(fo, output_jtidy);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -51,7 +51,7 @@ public class ApacheFOPConvertHTMLTest {
|
||||
public void whenTransformFromHeroldToPDF_thenCorrect() throws Exception {
|
||||
fromHTMLTOXMLUsingHerold();
|
||||
final Document fo = fromXMLFileToFO();
|
||||
fromFODocumentToPDF(fo, output2);
|
||||
fromFODocumentToPDF(fo, output_herold);
|
||||
}
|
||||
|
||||
private Document fromHTMLToXHTML() throws FileNotFoundException {
|
||||
@@ -92,7 +92,7 @@ public class ApacheFOPConvertHTMLTest {
|
||||
|
||||
private void fromFOFileToPDF() throws Exception {
|
||||
final FopFactory fopFactory = FopFactory.newInstance();
|
||||
final OutputStream outStream = new BufferedOutputStream(new FileOutputStream(new File(output1)));
|
||||
final OutputStream outStream = new BufferedOutputStream(new FileOutputStream(new File(output_html2fo)));
|
||||
final Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, outStream);
|
||||
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
|
||||
<!-- Creator="html2fo" Version="0.4.2" -->
|
||||
<fo:layout-master-set>
|
||||
<fo:simple-page-master margin-right="2.0cm" margin-left="2.0cm" margin-bottom="1.0cm" margin-top="1.0cm" page-width="21cm" page-height="29.7cm" master-name="first">
|
||||
<fo:region-body margin-bottom="1.5cm" margin-top="1.5cm"/>
|
||||
<fo:region-before extent="1.5cm"/>
|
||||
<fo:region-after extent="1.0cm"/>
|
||||
</fo:simple-page-master>
|
||||
</fo:layout-master-set>
|
||||
<fo:page-sequence master-reference="first" language="en" hyphenate="true">
|
||||
|
||||
|
||||
|
||||
<fo:static-content flow-name="xsl-region-before">
|
||||
<fo:block line-height="12pt" font-size="10pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always">Hello World</fo:block></fo:static-content>
|
||||
|
||||
<fo:static-content flow-name="xsl-region-after">
|
||||
<fo:block line-height="12pt" font-size="10pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always">
|
||||
|
||||
... the footer should be inserted here ...
|
||||
|
||||
</fo:block></fo:static-content>
|
||||
|
||||
<fo:flow flow-name="xsl-region-body">
|
||||
<fo:block space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" font-weight="bold" line-height="32pt" font-size="16pt">My name is John Doe</fo:block>
|
||||
<fo:block line-height="12pt" font-size="10pt" space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always"> Hello World!</fo:block>
|
||||
<fo:block space-before.optimum="1.5pt" space-after.optimum="1.5pt" keep-together="always" id="LastPage" line-height="1pt" font-size="1pt"></fo:block></fo:flow>
|
||||
</fo:page-sequence></fo:root>
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My name is John Doe</h1>
|
||||
<p> Hello World!</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Binary file not shown.
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<article version="5.0" xml:lang="en" xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink">
|
||||
<info>
|
||||
<title>Hello World</title>
|
||||
</info>
|
||||
<section>
|
||||
<title>My name is John Doe</title>
|
||||
<para> Hello World!</para>
|
||||
</section>
|
||||
</article>
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user