Search in sources :

Example 1 with Inline

use of org.docx4j.dml.wordprocessingDrawing.Inline in project Java-Tutorial by gpcodervn.

the class ImageAddTest method testSize20NoUnits.

@Test
public void testSize20NoUnits() throws Exception {
    // // values in dots are 20x as expected
    Inline inline1 = getInline("<div><img src='" + PNG_IMAGE_DATA + "' width='20' height='20' /></div>");
    Assert.assertTrue(inline1.getExtent().getCx() == 338667);
}
Also used : Inline(org.docx4j.dml.wordprocessingDrawing.Inline) Test(org.junit.Test)

Example 2 with Inline

use of org.docx4j.dml.wordprocessingDrawing.Inline in project Java-Tutorial by gpcodervn.

the class ImageAddTest method testSizeUnspecified.

@Test
public void testSizeUnspecified() throws Exception {
    Inline inline1 = getInline("<div><img src='" + PNG_IMAGE_DATA + "'/></div>");
    Assert.assertTrue(inline1.getExtent().getCx() == 25400);
}
Also used : Inline(org.docx4j.dml.wordprocessingDrawing.Inline) Test(org.junit.Test)

Example 3 with Inline

use of org.docx4j.dml.wordprocessingDrawing.Inline in project Java-Tutorial by gpcodervn.

the class ImageAddTest method testSize20px.

@Test
public void testSize20px() throws Exception {
    Inline inline1 = getInline("<div><img src='" + PNG_IMAGE_DATA + "' width='20px' height='20px' /></div>");
    Assert.assertTrue(inline1.getExtent().getCx() == 338667);
}
Also used : Inline(org.docx4j.dml.wordprocessingDrawing.Inline) Test(org.junit.Test)

Example 4 with Inline

use of org.docx4j.dml.wordprocessingDrawing.Inline in project Java-Tutorial by gpcodervn.

the class ImageResizeTest method testFixedSizeImage.

@Test
public void testFixedSizeImage() throws Exception {
    Inline inline1 = getInline("<div><img src='" + PNG_IMAGE_DATA + "'/></div>");
    Inline inline2 = getInline("<div><img src='" + PNG_IMAGE_DATA + "' width='40px' height='20px' /></div>");
    Assert.assertTrue(inline2.getExtent().getCx() / inline1.getExtent().getCx() == 26);
    Assert.assertTrue(inline2.getExtent().getCy() / inline1.getExtent().getCy() == 13);
}
Also used : Inline(org.docx4j.dml.wordprocessingDrawing.Inline) Test(org.junit.Test)

Example 5 with Inline

use of org.docx4j.dml.wordprocessingDrawing.Inline in project Java-Tutorial by gpcodervn.

the class ImageResizeTest method testScaling.

@Test
public void testScaling() throws Exception {
    Inline inline = getInline("<div><img src='" + PNG_IMAGE_DATA + "' style='width: 50px'/></div>");
    Assert.assertTrue(Math.round(inline.getExtent().getCx() / 10) == // +/- a few EMU
    Math.round(inline.getExtent().getCy() / 10));
}
Also used : Inline(org.docx4j.dml.wordprocessingDrawing.Inline) Test(org.junit.Test)

Aggregations

Inline (org.docx4j.dml.wordprocessingDrawing.Inline)26 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)16 P (org.docx4j.wml.P)10 R (org.docx4j.wml.R)10 Test (org.junit.Test)10 Drawing (org.docx4j.wml.Drawing)9 Jc (org.docx4j.wml.Jc)5 PPr (org.docx4j.wml.PPr)5 CTVerticalJc (org.docx4j.wml.CTVerticalJc)4 ObjectFactory (org.docx4j.wml.ObjectFactory)4 STVerticalJc (org.docx4j.wml.STVerticalJc)4 Text (org.docx4j.wml.Text)4 File (java.io.File)3 BigInteger (java.math.BigInteger)2 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)2 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)2 CTBorder (org.docx4j.wml.CTBorder)2 PBdr (org.docx4j.wml.PPrBase.PBdr)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1