-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#411 add few samples of html with lists
Unfortunately, these do not check how lists look like. But it least it's easy to check the result manually.
- Loading branch information
Showing
3 changed files
with
311 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
flying-saucer-pdf/src/test/java/org/xhtmlrenderer/pdf/ListsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.xhtmlrenderer.pdf; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.w3c.dom.Document; | ||
import org.xml.sax.InputSource; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.StringReader; | ||
|
||
public class ListsTest { | ||
private static final Logger log = LoggerFactory.getLogger(ListsTest.class); | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"page-with-lists.html", "list-sample.xhtml"}) | ||
void pageWithLists(String fileName) throws IOException, ParserConfigurationException, SAXException { | ||
InputStream htmlStream = getClass().getClassLoader().getResourceAsStream(fileName); | ||
String htmlContent = new String(htmlStream.readAllBytes()); | ||
|
||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder builder = factory.newDocumentBuilder(); | ||
Document document = builder.parse(new InputSource(new StringReader(htmlContent))); | ||
|
||
ITextRenderer renderer = new ITextRenderer(); | ||
|
||
ITextUserAgent userAgent = new ITextUserAgent(renderer.getOutputDevice(), Math.round(renderer.getOutputDevice().getDotsPerPoint())); | ||
renderer.getSharedContext().setUserAgentCallback(userAgent); | ||
|
||
renderer.setDocument(document, null); | ||
|
||
File result = new File("target", fileName + ".pdf"); | ||
try (FileOutputStream outputStream = new FileOutputStream(result)) { | ||
renderer.layout(); | ||
renderer.createPDF(outputStream); | ||
} | ||
log.info("PDF with lists: {}", result.getAbsolutePath()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html | ||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Flying Saucer: CSS List Support</title> | ||
<link rel="stylesheet" type="text/css" href="general.css" title="Style" media="screen" /> | ||
<link rel="stylesheet" type="text/css" href="print.css" title="Style" media="print" /> | ||
<style type="text/css"> | ||
h3 { font-weight: bold; } | ||
li { font-family: sans-serif; } | ||
|
||
#image-bullet li { list-style-image: url(bullet.gif); } | ||
#posout li { list-style-position: outside; } | ||
#posin li { list-style-position: inside; } | ||
#failover li { list-style-type: square; | ||
list-style-image: url(invalid.gif); } | ||
#shorthand li { list-style: square outside; } | ||
#inherit_test { list-style: square; } | ||
|
||
#square li { list-style-type: square; } | ||
#disc li { list-style-type: disc; } | ||
#circle li { list-style-type: circle; } | ||
#decimal li { list-style-type: decimal; } | ||
#decimal-leading-zero li { list-style-type: decimal-leading-zero; } | ||
#lower-roman li { list-style-type: lower-roman; } | ||
#upper-roman li { list-style-type: upper-roman; } | ||
#lower-greek li { list-style-type: lower-greek; } | ||
#lower-latin li { list-style-type: lower-latin; } | ||
#upper-latin li { list-style-type: upper-latin; } | ||
#none li { list-style-type: none; } | ||
</style> | ||
</head> | ||
<body> | ||
<p class="link left-link"><a href="demoNav:back">Previous Page</a></p> | ||
<p class="link right-link"><a href="demoNav:forward">Next Page</a></p> | ||
|
||
<p id="fslogo">Flying Saucer XML/CSS2 Renderer</p> | ||
<span id="pagebyline"> | ||
CSS | ||
<ul> | ||
<li>List</li> | ||
<li>Element</li> | ||
<li>Support</li> | ||
</ul> | ||
</span> | ||
<p><b>List support includes</b>: Full support for ordered and unordered lists, image bullets for lists, list style types, | ||
numbered lists, and so on.</p> | ||
<br /> | ||
|
||
<h3>Unordered List Items with default style</h3> | ||
|
||
<ul> | ||
|
||
<li>List text list text list text list text</li> | ||
|
||
<li>more item more item more item more item</li> | ||
|
||
</ul> | ||
|
||
<h3>Ordered List Items with default style</h3> | ||
<ol> | ||
<li>List text list text list text list text</li> | ||
<li>more item more item more item more item</li> | ||
</ol> | ||
|
||
<h3>List Items with image bullets</h3> | ||
<ol id="image-bullet"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Position Outside</h3> | ||
<ol id="posout"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Position Inside</h3> | ||
<ol id="posin"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Failover</h3> | ||
<p>The image shouldn't load and a square should be used instead</p> | ||
<ol id="failover"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Shorthand Test</h3> | ||
<p>It should have squares with outside position</p> | ||
<ol id="shorthand"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Inheritance test with squares</h3> | ||
<ol id="inherit_test"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Square Items</h3> | ||
<ol id="square"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Disc Items</h3> | ||
<ol id="disc"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Circle Items</h3> | ||
<ol id="circle"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
|
||
<h3>Decimal Items</h3> | ||
<ol id="decimal"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Decimal Leading Zero Items</h3> | ||
<p><i>Just does decimal for now</i></p> | ||
<ol id="decimal-leading-zero"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Lower Roman Items</h3> | ||
<p><i>Roman numerals not valid past 4000</i></p> | ||
<ol id="lower-roman"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Upper Roman Items</h3> | ||
<ol id="upper-roman"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Lower Greek Items</h3> | ||
<p><i>not supported yet. does decimal instead</i></p> | ||
<ol id="lower-greek"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Lower Latin Items</h3> | ||
<p><i>not tested past Z</i></p> | ||
<ol id="lower-latin"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>Upper Latin Items</h3> | ||
<ol id="upper-latin"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
<li>third item</li> | ||
<li>fourth item</li> | ||
<li>fifth item</li> | ||
<li>sixth item</li> | ||
</ol> | ||
|
||
<h3>None Items</h3> | ||
<ol id="none"> | ||
<li>first item</li> | ||
<li>second item</li> | ||
</ol> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | ||
<head> | ||
<title>Title Here</title> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | ||
<style type="text/css"> | ||
body { | ||
color: #3d3d3d; | ||
font-size: 12px; | ||
font-family: Arial, Helvetica, sans-serif; | ||
} | ||
|
||
h4 { | ||
margin-top: 4em; | ||
} | ||
|
||
li { | ||
margin-top: 1em; | ||
margin-bottom: 1em; | ||
padding: 10px 0; | ||
border: 1px dashed gray; | ||
} | ||
|
||
@page { | ||
size: 210mm 297mm; | ||
margin-top: 4cm; | ||
margin-bottom: 3cm; | ||
|
||
@bottom-left { | ||
font-size: 8px; | ||
color: #3d3d3d; | ||
content: element(footer) | ||
}; | ||
@top-center { | ||
content: element(header) | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<!--<div class="header" style="text-align: center;">Page Header</div>--> | ||
|
||
<ol> | ||
<li id="li.1.1">First list Item Goes Here</li> | ||
<li id="li.1.2">How to efficiently add a list</li> | ||
<li id="li.1.3">Steps to take when you are making a list</li> | ||
<li id="li.1.4">Our specific recommendations to you for lists.</li> | ||
</ol> | ||
|
||
<ul> | ||
<li id="li.2.1">Second list Item Goes Here</li> | ||
<li id="li.2.2">How to efficiently add a list</li> | ||
<li id="li.2.3">Steps to take when you are making a list</li> | ||
<li id="li.2.4">Our specific recommendations to you for lists.</li> | ||
</ul> | ||
|
||
</body> | ||
</html> |