Program: 74452
Project: 74452
Buggy source:
protected void drawBackgroundImage(float x,float y,float width,float height,String repeat,String imageUrl,float absPosX,float absPosY) throws IOException {
  y=transformY(y);
  cbUnder.saveState();
  Image img=null;
  try {
    img=Image.getInstance(imageUrl);
    if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      TplValueTriple triple=computeTplHorizontalValPair(absPosX,x,width,img.scaledWidth());
      float tplOriginX=triple.getTplOrigin();
      float tplWidth=triple.getTplSize();
      float translationX=triple.getTranslation();
      triple=computeTplVerticalValTriple(absPosY,y,height,img.scaledHeight());
      float tplOrininY=triple.getTplOrigin();
      float tplHeight=triple.getTplSize();
      float translationY=triple.getTranslation();
      PdfTemplate templateWhole=cbUnder.createTemplate(tplWidth,tplHeight);
      templateWhole.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),translationX,translationY);
      cbUnder.addTemplate(templateWhole,tplOriginX,tplOrininY);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainX=width;
      PdfTemplate template=null;
      if (width > img.scaledWidth()) {
        if (height - absPosY > img.scaledHeight()) {
          template=cbUnder.createTemplate(img.scaledWidth(),img.scaledHeight());
          template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
        }
 else {
          template=cbUnder.createTemplate(img.scaledWidth(),height);
          template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + height);
        }
      }
      while (remainX > 0) {
        if (remainX < img.scaledWidth()) {
          if (height - absPosY > img.scaledHeight()) {
            PdfTemplate templateX=cbUnder.createTemplate(remainX,img.scaledHeight());
            templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
            cbUnder.addTemplate(templateX,x + width - remainX,y - absPosY - img.scaledHeight());
          }
 else {
            PdfTemplate templateX=cbUnder.createTemplate(remainX,height);
            templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + height - absPosY);
            cbUnder.addTemplate(templateX,x + width - remainX,y - absPosY - height);
          }
          remainX=0;
        }
 else {
          if (height - absPosY > img.scaledHeight())           cbUnder.addTemplate(template,x + width - remainX,y - absPosY - img.scaledHeight());
 else           cbUnder.addTemplate(template,x + width - remainX,y - absPosY - height);
          remainX-=img.scaledWidth();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainY=height;
      PdfTemplate template=null;
      if (height > img.scaledHeight()) {
        template=cbUnder.createTemplate(width - absPosX > img.scaledWidth() ? img.scaledWidth() : width - absPosX,img.scaledHeight());
        template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
      }
      while (remainY > 0) {
        if (remainY < img.scaledHeight()) {
          PdfTemplate templateY=cbUnder.createTemplate(width - absPosX > img.scaledWidth() ? img.scaledWidth() : width - absPosX,remainY);
          templateY.addImage(img,width > img.scaledWidth() ? img.scaledWidth() : width - absPosX,0,0,img.scaledHeight(),0,-(img.scaledHeight() - remainY));
          cbUnder.addTemplate(templateY,x + absPosX,y - height);
          remainY=0;
        }
 else {
          cbUnder.addTemplate(template,x + absPosX,y - height + remainY - img.scaledHeight());
          remainY-=img.scaledHeight();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainX=width;
      float remainY=height;
      PdfTemplate template=null;
      if (width > img.scaledWidth() && height > img.scaledHeight()) {
        template=cbUnder.createTemplate(img.scaledWidth(),img.scaledHeight());
        template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
      }
      while (remainY > 0) {
        remainX=width;
        if (remainY < img.scaledHeight()) {
          while (remainX > 0) {
            if (remainX < img.scaledWidth()) {
              PdfTemplate templateXY=cbUnder.createTemplate(remainX,remainY);
              templateXY.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + remainY);
              cbUnder.addTemplate(templateXY,x + width - remainX,y - height);
              remainX=0;
            }
 else {
              PdfTemplate templateY=cbUnder.createTemplate(img.scaledWidth(),remainY);
              templateY.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + remainY);
              cbUnder.addTemplate(templateY,x + width - remainX,y - height);
              remainX-=img.scaledWidth();
            }
          }
          remainY=0;
        }
 else {
          while (remainX > 0) {
            if (remainX < img.scaledWidth()) {
              PdfTemplate templateX=cbUnder.createTemplate(remainX,img.scaledHeight());
              templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
              cbUnder.addTemplate(templateX,x + width - remainX,y - height + remainY - img.scaledHeight());
              remainX=0;
            }
 else {
              cbUnder.addTemplate(template,x + width - remainX,y - height + remainY - img.scaledHeight());
              remainX-=img.scaledWidth();
            }
          }
          remainY-=img.scaledHeight();
        }
      }
    }
  }
 catch (  IOException ioe) {
    logger.log(Level.WARNING,ioe.getMessage(),ioe);
  }
catch (  BadElementException bee) {
    logger.log(Level.WARNING,bee.getMessage(),bee);
  }
catch (  DocumentException de) {
    logger.log(Level.WARNING,de.getMessage(),de);
  }
catch (  RuntimeException re) {
    logger.log(Level.WARNING,re.getMessage(),re);
  }
  cbUnder.restoreState();
}

Fixed version (ground truth):
protected void drawBackgroundImage(float x,float y,float width,float height,String repeat,String imageUrl,float absPosX,float absPosY) throws IOException {
  y=transformY(y);
  contentByte.saveState();
  Image img=null;
  try {
    img=Image.getInstance(imageUrl);
    if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      TplValueTriple triple=computeTplHorizontalValPair(absPosX,x,width,img.scaledWidth());
      float tplOriginX=triple.getTplOrigin();
      float tplWidth=triple.getTplSize();
      float translationX=triple.getTranslation();
      triple=computeTplVerticalValTriple(absPosY,y,height,img.scaledHeight());
      float tplOrininY=triple.getTplOrigin();
      float tplHeight=triple.getTplSize();
      float translationY=triple.getTranslation();
      PdfTemplate templateWhole=contentByte.createTemplate(tplWidth,tplHeight);
      templateWhole.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),translationX,translationY);
      contentByte.addTemplate(templateWhole,tplOriginX,tplOrininY);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainX=width;
      PdfTemplate template=null;
      if (width > img.scaledWidth()) {
        if (height - absPosY > img.scaledHeight()) {
          template=contentByte.createTemplate(img.scaledWidth(),img.scaledHeight());
          template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
        }
 else {
          template=contentByte.createTemplate(img.scaledWidth(),height);
          template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + height);
        }
      }
      while (remainX > 0) {
        if (remainX < img.scaledWidth()) {
          if (height - absPosY > img.scaledHeight()) {
            PdfTemplate templateX=contentByte.createTemplate(remainX,img.scaledHeight());
            templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - img.scaledHeight());
          }
 else {
            PdfTemplate templateX=contentByte.createTemplate(remainX,height);
            templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + height - absPosY);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - height);
          }
          remainX=0;
        }
 else {
          if (height - absPosY > img.scaledHeight())           contentByte.addTemplate(template,x + width - remainX,y - absPosY - img.scaledHeight());
 else           contentByte.addTemplate(template,x + width - remainX,y - absPosY - height);
          remainX-=img.scaledWidth();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainY=height;
      PdfTemplate template=null;
      if (height > img.scaledHeight()) {
        template=contentByte.createTemplate(width - absPosX > img.scaledWidth() ? img.scaledWidth() : width - absPosX,img.scaledHeight());
        template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
      }
      while (remainY > 0) {
        if (remainY < img.scaledHeight()) {
          PdfTemplate templateY=contentByte.createTemplate(width - absPosX > img.scaledWidth() ? img.scaledWidth() : width - absPosX,remainY);
          templateY.addImage(img,width > img.scaledWidth() ? img.scaledWidth() : width - absPosX,0,0,img.scaledHeight(),0,-(img.scaledHeight() - remainY));
          contentByte.addTemplate(templateY,x + absPosX,y - height);
          remainY=0;
        }
 else {
          contentByte.addTemplate(template,x + absPosX,y - height + remainY - img.scaledHeight());
          remainY-=img.scaledHeight();
        }
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(repeat)) {
      float remainX=width;
      float remainY=height;
      PdfTemplate template=null;
      if (width > img.scaledWidth() && height > img.scaledHeight()) {
        template=contentByte.createTemplate(img.scaledWidth(),img.scaledHeight());
        template.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
      }
      while (remainY > 0) {
        remainX=width;
        if (remainY < img.scaledHeight()) {
          while (remainX > 0) {
            if (remainX < img.scaledWidth()) {
              PdfTemplate templateXY=contentByte.createTemplate(remainX,remainY);
              templateXY.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + remainY);
              contentByte.addTemplate(templateXY,x + width - remainX,y - height);
              remainX=0;
            }
 else {
              PdfTemplate templateY=contentByte.createTemplate(img.scaledWidth(),remainY);
              templateY.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,-img.scaledHeight() + remainY);
              contentByte.addTemplate(templateY,x + width - remainX,y - height);
              remainX-=img.scaledWidth();
            }
          }
          remainY=0;
        }
 else {
          while (remainX > 0) {
            if (remainX < img.scaledWidth()) {
              PdfTemplate templateX=contentByte.createTemplate(remainX,img.scaledHeight());
              templateX.addImage(img,img.scaledWidth(),0,0,img.scaledHeight(),0,0);
              contentByte.addTemplate(templateX,x + width - remainX,y - height + remainY - img.scaledHeight());
              remainX=0;
            }
 else {
              contentByte.addTemplate(template,x + width - remainX,y - height + remainY - img.scaledHeight());
              remainX-=img.scaledWidth();
            }
          }
          remainY-=img.scaledHeight();
        }
      }
    }
  }
 catch (  IOException ioe) {
    logger.log(Level.WARNING,ioe.getMessage(),ioe);
  }
catch (  BadElementException bee) {
    logger.log(Level.WARNING,bee.getMessage(),bee);
  }
catch (  DocumentException de) {
    logger.log(Level.WARNING,de.getMessage(),de);
  }
catch (  RuntimeException re) {
    logger.log(Level.WARNING,re.getMessage(),re);
  }
  contentByte.restoreState();
}