Skip to content

Commit 46591db

Browse files
author
dmitry.radchuk
committed
Refactor commented tests in PdfCanvasTest
DEVSIX-6484
1 parent f15fb9a commit 46591db

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ This file is part of the iText (R) project.
4343
package com.itextpdf.barcodes;
4444

4545
import com.itextpdf.barcodes.exceptions.BarcodeExceptionMessageConstant;
46+
import com.itextpdf.io.codec.CCITTG4Encoder;
4647
import com.itextpdf.io.image.ImageData;
4748
import com.itextpdf.io.image.ImageDataFactory;
49+
import com.itextpdf.io.image.RawImageData;
4850
import com.itextpdf.kernel.colors.ColorConstants;
4951
import com.itextpdf.kernel.exceptions.PdfException;
5052
import com.itextpdf.kernel.pdf.PdfDocument;
@@ -488,6 +490,37 @@ public void lenCodewordsMoreThanMaxDataCodewordsTest() {
488490
Assert.assertEquals(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage());
489491
}
490492

493+
@Test
494+
public void ccittImageFromBarcodeTest() throws IOException, InterruptedException {
495+
String filename = "ccittImage01.pdf";
496+
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
497+
PdfDocument document = new PdfDocument(writer);
498+
499+
PdfPage page = document.addNewPage();
500+
PdfCanvas canvas = new PdfCanvas(page);
501+
502+
String text = "Call me Ishmael. Some years ago--never mind how long "
503+
+ "precisely --having little or no money in my purse, and nothing "
504+
+ "particular to interest me on shore, I thought I would sail about "
505+
+ "a little and see the watery part of the world.";
506+
507+
BarcodePDF417 barcode = new BarcodePDF417();
508+
barcode.setCode(text);
509+
barcode.paintCode();
510+
511+
byte g4[] = CCITTG4Encoder.compress(barcode.getOutBits(), barcode.getBitColumns(), barcode.getCodeRows());
512+
ImageData img = ImageDataFactory.create(barcode.getBitColumns(), barcode.getCodeRows(), false,
513+
RawImageData.CCITTG4, 0, g4, null);
514+
515+
canvas.addImageAt(img, 100, 100, false);
516+
517+
document.close();
518+
519+
Assert.assertNull(
520+
new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename,
521+
DESTINATION_FOLDER, "diff_"));
522+
}
523+
491524
private PdfFormXObject createMacroBarcodePart(PdfDocument document, String text, float mh, float mw, int segmentId) {
492525
BarcodePDF417 pf = new BarcodePDF417();
493526

Binary file not shown.

kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,52 +1346,6 @@ public void gifImageTest05() throws IOException, InterruptedException {
13461346
DESTINATION_FOLDER, "diff_"));
13471347
}
13481348

1349-
// @Test
1350-
// public void kernedTextTest01() throws IOException, InterruptedException {
1351-
// FileOutputStream fos = new FileOutputStream(destinationFolder + "kernedTextTest01.pdf");
1352-
// PdfWriter writer = new PdfWriter(fos);
1353-
// PdfDocument document = new PdfDocument(writer);
1354-
// PdfPage page = document.addNewPage();
1355-
//
1356-
// PdfCanvas canvas = new PdfCanvas(page);
1357-
// String kernableText = "AVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAVAV";
1358-
// PdfFont font = PdfFont.createFont(document, StandardFonts.HELVETICA);
1359-
// canvas.beginText().moveText(50, 600).setFontAndSize(font, 12).showText("Kerning:-" + kernableText).endText();
1360-
// canvas.beginText().moveText(50, 650).setFontAndSize(font, 12).showTextKerned("Kerning:+" + kernableText).endText();
1361-
//
1362-
// document.close();
1363-
//
1364-
// Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "kernedTextTest01.pdf", sourceFolder + "cmp_kernedTextTest01.pdf", destinationFolder, "diff_"));
1365-
// }
1366-
1367-
/*@Test
1368-
public void ccittImageTest01() throws IOException, InterruptedException {
1369-
String filename = "ccittImage01.pdf";
1370-
PdfWriter writer = new PdfWriter(destinationFolder + filename);
1371-
PdfDocument document = new PdfDocument(writer);
1372-
1373-
PdfPage page = document.addNewPage();
1374-
PdfCanvas canvas = new PdfCanvas(page);
1375-
1376-
String text = "Call me Ishmael. Some years ago--never mind how long "
1377-
+ "precisely --having little or no money in my purse, and nothing "
1378-
+ "particular to interest me on shore, I thought I would sail about "
1379-
+ "a little and see the watery part of the world.";
1380-
1381-
BarcodePDF417 barcode = new BarcodePDF417();
1382-
barcode.setText(text);
1383-
barcode.paintCode();
1384-
1385-
byte g4[] = CCITTG4Encoder.compress(barcode.getOutBits(), barcode.getBitColumns(), barcode.getCodeRows());
1386-
RawImage img = (RawImage) ImageDataFactory.create(barcode.getBitColumns(), barcode.getCodeRows(), false, RawImage.CCITTG4, 0, g4, null);
1387-
img.setTypeCcitt(RawImage.CCITTG4);
1388-
canvas.addImage(img, 100, 100, false);
1389-
1390-
document.close();
1391-
1392-
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
1393-
}*/
1394-
13951349
@Test
13961350
public void awtImagesTest01() throws IOException, InterruptedException {
13971351
String filename = "awtImagesTest01.pdf";

0 commit comments

Comments
 (0)