Posted by a ceTe Software moderator
Hello,
You can add images, tables and text contents to the PDF using our DynamicPDF for java API. You will need to use the respective page element to add the contents to the PDF. Also you can control the positions and dimensions using Width, Height, X and Y properties of the respective page elements. Please refer to the documentation on page elements
here.
You can add text around the image without any problem using our DynamicPDF for Java API. Below is the code sample for it. Please refer to the documentation on
Image and
TextArea classes.
Document document=new Document();
Page page=new Page();
document.getPages().add(page);
Image image=new Image("D:\\temporary\\Images\\Winter.jpg",0F,0F);
image.setWidth(200);
image.setHeight(200);
page.getElements().add(image);
String text="This is to test the text in the PDF using java API";
for (int j = 0; j < 5; j++)
{
text = text + text;
}
TextArea area=new TextArea(text, image.getX()+image.getWidth()+2,image.getY(),100,100);
area.setHeight(image.getHeight());
page.getElements().add(area);
if(area.hasOverflowText())
{
float newX=image.getX() ;
float newY=image.getY()+image.getHeight();
float newWidth= image.getWidth() + area.getWidth();
area=area.getOverflowTextArea(newX,newY);
area.setWidth(newWidth);
area.setHeight(area.getRequiredHeight());
page.getElements().add(area);
}
document.draw("C:\\Temp\\Myoutput_Java.pdf");
You can download evaluation version of DynamicPDF Generator for Java product from our website
here. Also refer to the code samples included with the evaluation download.
Thanks,
ceTe Software Support Team.