@@ -46,9 +46,12 @@ This file is part of the iText (R) project.
46
46
import com .itextpdf .kernel .pdf .PdfDocument ;
47
47
import com .itextpdf .kernel .pdf .PdfWriter ;
48
48
import com .itextpdf .kernel .utils .CompareTool ;
49
+ import com .itextpdf .layout .element .AreaBreak ;
49
50
import com .itextpdf .layout .element .Paragraph ;
51
+ import com .itextpdf .layout .element .Text ;
50
52
import com .itextpdf .layout .hyphenation .HyphenationConfig ;
51
53
import com .itextpdf .layout .hyphenation .Hyphenator ;
54
+ import com .itextpdf .layout .property .TextAlignment ;
52
55
import com .itextpdf .test .ExtendedITextTest ;
53
56
import com .itextpdf .test .annotations .type .IntegrationTest ;
54
57
import org .junit .Assert ;
@@ -91,4 +94,61 @@ public void parenthesisTest01() throws Exception {
91
94
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" ));
92
95
}
93
96
97
+ @ Test
98
+ public void uriTest01 () throws Exception {
99
+ String outFileName = destinationFolder + "uriTest01.pdf" ;
100
+ String cmpFileName = sourceFolder + "cmp_uriTest01.pdf" ;
101
+
102
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
103
+ Document document = new Document (pdfDoc , new PageSize (140 , 500 ));
104
+
105
+ Hyphenator hyphenator = new Hyphenator ("en" , "en" , 3 , 3 );
106
+ HyphenationConfig hyphenationConfig = new HyphenationConfig (hyphenator );
107
+ document .setHyphenation (hyphenationConfig );
108
+
109
+ Paragraph p = new Paragraph ("https://stackoverflow.com/" );
110
+ document .add (p );
111
+ p = new Paragraph ("http://stackoverflow.com/" );
112
+ document .add (p );
113
+ p = new Paragraph ("m://iiiiiiii.com/" );
114
+ document .add (p );
115
+
116
+ document .add (new AreaBreak ());
117
+
118
+ p = new Paragraph ("https://stackoverflow.com/" );
119
+ p .setHyphenation (null );
120
+ document .add (p );
121
+ p = new Paragraph ("http://stackoverflow.com/" );
122
+ p .setHyphenation (null );
123
+ document .add (p );
124
+ p = new Paragraph ("m://iiiiiiii.com/" );
125
+ p .setHyphenation (null );
126
+ document .add (p );
127
+
128
+ document .close ();
129
+
130
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" ));
131
+ }
132
+
133
+ @ Test
134
+ public void widthTest01 () throws Exception {
135
+ String outFileName = destinationFolder + "widthTest01.pdf" ;
136
+ String cmpFileName = sourceFolder + "cmp_widthTest01.pdf" ;
137
+
138
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
139
+ Document doc = new Document (pdfDoc );
140
+
141
+ Text text = new Text ("Hier ein link https://stackoverflow " + "\n " + " (Sperrvermerk) (Sperrvermerk)" + "\n " + "„Sperrvermerk“ „Sperrvermerk“" + "\n " + "Der Sperrvermerk Sperrvermerk" + "\n " + "correct Sperr|ver|merk" );
142
+ Paragraph paragraph = new Paragraph (text );
143
+ paragraph .setWidth (150 );
144
+ paragraph .setTextAlignment (TextAlignment .JUSTIFIED );
145
+ paragraph .setHyphenation (new HyphenationConfig ("de" , "DE" , 2 , 2 ));
146
+
147
+ doc .add (paragraph );
148
+
149
+ doc .close ();
150
+
151
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" ));
152
+ }
153
+
94
154
}
0 commit comments