Text flowing around images

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v7.x)  /  Display Thread

DynamicPDF Generator for Java (v7.x) Forum

 Jul 17 2014 6:58 PM
I am currently evaluating your Java offering for use with our software.

One of the main requirements we have is for flexible and easy to use page layout.

Within this we we like to be be able to position components on a PDF page e.g. images, tables and we would then like to add text content to the page that would "flow" nicely round the other components irrespective of their position on the page.

Is this something that can be achieved by your software, I have read your online documentation but see not obvious solution.
 Jul 18 2014 10:42 AM
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.

All times are US Eastern Standard time. The time now is 8:51 AM.