图片靠左对齐
示例代码
package test.create.c03;
import iofd.layout.OfdDocument;
import iofd.layout.block.OfdImage;
import iofd.layout.block.Paragraph;
import iofd.layout.contants.AlignmentType;
import java.io.File;
import test.create.TestDocUtil;
import test.create.resource.TestFileResource;
/**
* 添加图片的示例,图片靠左对齐
* */
public class C0302ImageSetAlignLeft {
public static void main(String[] args) throws Throwable {
C0302ImageSetAlignLeft o = new C0302ImageSetAlignLeft();
o.done();
}
private void done() throws Throwable {
String clzName = this.getClass().getSimpleName();
System.out.println(clzName + " begin");
OfdDocument doc = new OfdDocument();
String s = "这是一个插入图片的示例,图片靠左对齐。";
Paragraph p = new Paragraph();
p.add(s);
doc.add(p);
File imageFile = new File(TestFileResource.class.getResource("400X300px2.jpg").toURI());
OfdImage image = new OfdImage(imageFile);
/*
* 图片靠左对齐
* */
image.setImageAlignment(AlignmentType.LEFT);
doc.add(image);
String fileName = TestDocUtil.getOfdFilePath(this.getClass());
doc.save(fileName);
System.out.println(clzName + " end");
}
}