@@ -43,6 +43,7 @@ This file is part of the iText (R) project.
43
43
package com .itextpdf .layout ;
44
44
45
45
import com .itextpdf .io .LogMessageConstant ;
46
+ import com .itextpdf .io .image .ImageData ;
46
47
import com .itextpdf .io .image .ImageDataFactory ;
47
48
import com .itextpdf .io .util .UrlUtil ;
48
49
import com .itextpdf .kernel .colors .ColorConstants ;
@@ -943,4 +944,48 @@ public void imageBorderRadiusTest01() throws IOException, InterruptedException {
943
944
944
945
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff" ));
945
946
}
947
+
948
+ @ Test
949
+ @ LogMessages (messages = {@ LogMessage (messageTemplate = LogMessageConstant .ELEMENT_DOES_NOT_FIT_AREA , count = 3 )})
950
+ public void createTiffImageTest () throws IOException , InterruptedException {
951
+ String outFileName = destinationFolder + "createTiffImageTest.pdf" ;
952
+ String cmpFileName = sourceFolder + "cmp_createTiffImageTest.pdf" ;
953
+ String imgPath = sourceFolder + "group4Compression.tif" ;
954
+
955
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
956
+ Document document = new Document (pdfDoc );
957
+
958
+ ImageData id = ImageDataFactory .create (imgPath );
959
+
960
+ ImageData idAsTiff = ImageDataFactory
961
+ .createTiff (UrlUtil .toURL (imgPath ), true , 1 , true );
962
+
963
+ ImageData idAsTiffFalse = ImageDataFactory
964
+ .createTiff (UrlUtil .toURL (imgPath ), false , 1 , false );
965
+
966
+ document .add (new Image (id ));
967
+ document .add (new Image (idAsTiff ));
968
+ document .add (new Image (idAsTiffFalse ));
969
+
970
+ document .close ();
971
+
972
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
973
+ }
974
+
975
+ @ Test
976
+ public void tiffImageWithoutCompressionTest () throws IOException , InterruptedException {
977
+ String outFileName = destinationFolder + "tiffImageWithoutCompression.pdf" ;
978
+ String cmpFileName = sourceFolder + "cmp_tiffImageWithoutCompression.pdf" ;
979
+ String imgPath = sourceFolder + "no-compression-tag.tiff" ;
980
+
981
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
982
+ Document document = new Document (pdfDoc );
983
+
984
+ ImageData id = ImageDataFactory .create (imgPath );
985
+ document .add (new Image (id ));
986
+
987
+ document .close ();
988
+
989
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff02_" ));
990
+ }
946
991
}
0 commit comments