AnsweredAssumed Answered

Overlay picture

Question asked by tanaka on Mar 16, 2017

Hello

 

For the Alfresco viewer program in Mozilla firefox 5, I can see a pdf in dimension 21cm * 29.7 cm or on two page when the documents own several pages.

 

A script in java was written to place a picture ( format of picture is in png/jpeg/jpg/gif ... ) on the viewer program for pdf file . To merge pdf with the picture this code was written to calculate the position of picture in pdf file :

 

[code="java"]protected Rectangle positionBlock(String position, Rectangle pageRect, int width, int height)
    {

 

    float pageHeight = pageRect.getHeight();
    float pageWidth = pageRect.getWidth();
   
    Rectangle r = null;
    //Rectangle constructor(float llx, float lly, float urx, float ury)
    if (position.equals(POSITION_BOTTOMLEFT))
    {
    r = new Rectangle(0, height, width, 0);
    }
    else if (position.equals(POSITION_BOTTOMCENTER))
    {
    r = new Rectangle(width, height, (pageWidth - width), 0);
    }
    else if (position.equals(POSITION_BOTTOMRIGHT))
    {
    r = new Rectangle((pageWidth - (width / 2)), height, pageWidth, 0);
    }
    else if (position.equals(POSITION_TOPLEFT))
    {
    r = new Rectangle(0, pageHeight, width, (pageHeight - height));
    }
    else if (position.equals(POSITION_TOPCENTER))
    {
    r = new Rectangle(width, pageHeight, (pageWidth - width), (pageHeight - height));
    }
    else if (position.equals(POSITION_TOPRIGHT))
    {
    r = new Rectangle((pageWidth - (width / 2)), pageHeight, pageWidth, (pageHeight - height));
    }
    else if (position.equals(POSITION_CENTERLEFT))
    {
    r = new Rectangle(0, ((pageHeight / 2) + height), width, (pageHeight / 2));
    }
    else if (position.equals(POSITION_CENTER))
    {
    r = new Rectangle(width, ((pageHeight / 2) + height), (pageWidth - width), (pageHeight / 2));
    }
    else if (position.equals(POSITION_CENTERRIGHT))
    {
    r = new Rectangle((pageWidth - (width / 2)), ((pageHeight / 2) + height), pageWidth, (pageHeight / 2));
    }
    return r;
    }

[/code]

 

The picture can own 9 positions in the pdf file.

 

But when I see the picture this is always in the center of the pdf file.

 

Can you give me your opinion to place this picture in each position and not only in the middle of the document ?

Outcomes