@@ -43,18 +43,24 @@ This file is part of the iText (R) project.
43
43
package com .itextpdf .svg .processors .impl .font ;
44
44
45
45
46
+ import com .itextpdf .io .util .FileUtil ;
47
+ import com .itextpdf .kernel .pdf .WriterProperties ;
46
48
import com .itextpdf .kernel .utils .CompareTool ;
49
+ import com .itextpdf .styledxmlparser .css .media .MediaDeviceDescription ;
50
+ import com .itextpdf .styledxmlparser .css .media .MediaType ;
51
+ import com .itextpdf .styledxmlparser .resolver .font .BasicFontProvider ;
47
52
import com .itextpdf .svg .exceptions .SvgLogMessageConstant ;
53
+ import com .itextpdf .svg .processors .ISvgConverterProperties ;
54
+ import com .itextpdf .svg .processors .impl .SvgConverterProperties ;
48
55
import com .itextpdf .svg .renderers .SvgIntegrationTest ;
49
56
import com .itextpdf .test .ITextTest ;
50
57
import com .itextpdf .test .annotations .LogMessage ;
51
58
import com .itextpdf .test .annotations .LogMessages ;
52
59
import com .itextpdf .test .annotations .type .IntegrationTest ;
53
-
60
+ import java . io . File ;
54
61
import java .io .FileInputStream ;
55
62
import java .io .FileOutputStream ;
56
63
import java .io .IOException ;
57
-
58
64
import org .junit .Assert ;
59
65
import org .junit .BeforeClass ;
60
66
import org .junit .Ignore ;
@@ -225,11 +231,73 @@ public void fontFamilyTest01() throws IOException, InterruptedException {
225
231
runTest ("fontFamilyTest01" );
226
232
}
227
233
228
- private void runTest (String fileName ) throws IOException , InterruptedException {
229
- convert (sourceFolder + fileName + ".svg" ,destinationFolder + fileName + ".pdf" );
230
- CompareTool compareTool = new CompareTool ();
231
- String compareResult = compareTool .compareByContent (destinationFolder + fileName + ".pdf" , sourceFolder + "cmp_" + fileName + ".pdf" , destinationFolder , "diff_" );
232
- Assert .assertNull (compareResult );
234
+ @ Test
235
+ public void resolveFontsWithoutWriterProperties () throws IOException , InterruptedException {
236
+ String fileName = "fontSelectorTest" ;
237
+ ISvgConverterProperties properties = new SvgConverterProperties ().setFontProvider (new BasicFontProvider ()).setMediaDeviceDescription (new MediaDeviceDescription (MediaType .ALL ));
238
+ convertToSinglePage (new File (sourceFolder + fileName + ".svg" ), new File (destinationFolder + fileName + ".pdf" ), properties );
239
+ compare (fileName , sourceFolder , destinationFolder );
240
+ }
241
+
242
+ @ Test
243
+ public void resolveFontsWithoutConverterPropertiesAndWriterProperties () throws IOException , InterruptedException {
244
+ String fileName = "resolveFonts_WithoutConverterPropertiesAndWriterProperties" ;
245
+ String svgFile = "fontSelectorTest" ;
246
+ convertToSinglePage (new File (sourceFolder + svgFile + ".svg" ), new File (destinationFolder + fileName + ".pdf" ));
247
+ compare (fileName , sourceFolder , destinationFolder );
248
+ }
249
+
250
+ @ Test
251
+ public void resolveFontsWithAllProperties () throws IOException , InterruptedException {
252
+ String fileName = "resolveFonts_WithAllProperties" ;
253
+ String svgFile = "fontSelectorTest" ;
254
+ WriterProperties writerprops = new WriterProperties ().setCompressionLevel (0 );
255
+ String baseUri = FileUtil .getParentDirectory (new File (sourceFolder + svgFile + ".svg" ));
256
+ ISvgConverterProperties properties = new SvgConverterProperties ().setBaseUri (baseUri ).setFontProvider (new BasicFontProvider ()).setMediaDeviceDescription (new MediaDeviceDescription (MediaType .ALL ));
257
+ convertToSinglePage (new File (sourceFolder + svgFile + ".svg" ), new File (destinationFolder + fileName + ".pdf" ), properties , writerprops );
258
+ compare (fileName , sourceFolder , destinationFolder );
259
+ }
260
+
261
+ @ Test
262
+ public void resolveFontsWithWriterProperties () throws IOException , InterruptedException {
263
+ String fileName = "resolveFonts_WithWriterProperties" ;
264
+ String svgFile = "fontSelectorTest" ;
265
+ WriterProperties writerprops = new WriterProperties ().setCompressionLevel (0 );
266
+ convertToSinglePage (new File (sourceFolder + svgFile + ".svg" ), new File (destinationFolder + fileName + ".pdf" ), writerprops );
267
+ compare (fileName , sourceFolder , destinationFolder );
268
+ }
269
+
270
+ @ Test
271
+ public void resolveFontsWithConverterPropsAndWriterProps () throws IOException , InterruptedException {
272
+ String fileName = "resolveFonts_WithConverterPropsAndWriterProps" ;
273
+ String svgFile = "fontSelectorTest" ;
274
+ WriterProperties writerprops = new WriterProperties ().setCompressionLevel (0 );
275
+ String baseUri = FileUtil .getParentDirectory (new File (sourceFolder + svgFile + ".svg" ));
276
+ ISvgConverterProperties properties = new SvgConverterProperties ().setBaseUri (baseUri ).setFontProvider (new BasicFontProvider ()).setMediaDeviceDescription (new MediaDeviceDescription (MediaType .ALL ));
277
+ convertToSinglePage (new FileInputStream (sourceFolder + svgFile + ".svg" ), new FileOutputStream (destinationFolder + fileName + ".pdf" ), properties , writerprops );
278
+ compare (fileName , sourceFolder , destinationFolder );
279
+ }
280
+
281
+ @ Test
282
+ public void resolveFontsWithConverterPropertiesAndEmptyUri () throws IOException , InterruptedException {
283
+ String fileName = "resolveFonts_WithConverterPropertiesAndEmptyUri" ;
284
+ String svgFile = "fontSelectorTest" ;
285
+ ISvgConverterProperties properties = new SvgConverterProperties ().setBaseUri ("" ).setFontProvider (new BasicFontProvider ()).setMediaDeviceDescription (new MediaDeviceDescription (MediaType .ALL ));
286
+ convertToSinglePage (new File (sourceFolder + svgFile + ".svg" ), new File (destinationFolder + fileName + ".pdf" ), properties );
287
+ compare (fileName , sourceFolder , destinationFolder );
288
+ }
289
+
290
+ @ Test
291
+ public void resolveFontsWithConverterPropertiesAndNullUri () throws IOException , InterruptedException {
292
+ String fileName = "resolveFonts_WithConverterPropertiesAndNullUri" ;
293
+ String svgFile = "fontSelectorTest" ;
294
+ ISvgConverterProperties properties = new SvgConverterProperties ().setBaseUri (null ).setFontProvider (new BasicFontProvider ()).setMediaDeviceDescription (new MediaDeviceDescription (MediaType .ALL ));
295
+ convertToSinglePage (new File (sourceFolder + svgFile + ".svg" ), new File (destinationFolder + fileName + ".pdf" ), properties );
296
+ compare (fileName , sourceFolder , destinationFolder );
297
+ }
233
298
299
+ private void runTest (String fileName ) throws IOException , InterruptedException {
300
+ convert (sourceFolder + fileName + ".svg" , destinationFolder + fileName + ".pdf" );
301
+ compare (fileName , sourceFolder , destinationFolder );
234
302
}
235
303
}
0 commit comments