Program: 69390
Project: 69390
Buggy source:
protected void drawBackgroundImage(float x,float y,float width,float height,float iWidth,float iHeight,int repeat,String imageUrl,float absPosX,float absPosY) throws IOException {
  y=transformY(y);
  contentByte.saveState();
  try {
    Image img=null;
    try {
      img=Image.getInstance(new URL(imageUrl));
    }
 catch (    IOException e) {
      if (SvgFile.isSvg(imageUrl)) {
        try {
          img=Image.getInstance(SvgFile.transSvgToArray(imageUrl));
        }
 catch (        IOException ex) {
          throw ex;
        }
      }
 else {
        throw e;
      }
    }
    float imageWidth=iWidth;
    float imageHeight=iHeight;
    if (imageHeight == 0 || imageWidth == 0) {
      int resolutionX=img.getDpiX();
      int resolutionY=img.getDpiY();
      if (0 == resolutionX || 0 == resolutionY) {
        resolutionX=96;
        resolutionY=96;
      }
      imageWidth=img.plainWidth() / resolutionX * 72;
      imageHeight=img.plainHeight() / resolutionY * 72;
    }
    if (BackgroundImageInfo.NO_REPEAT == repeat) {
      TplValueTriple triple=computeTplHorizontalValPair(absPosX,x,width,imageWidth);
      float tplOriginX=triple.getTplOrigin();
      float tplWidth=triple.getTplSize();
      float translationX=triple.getTranslation();
      triple=computeTplVerticalValTriple(absPosY,y,height,imageHeight);
      float tplOrininY=triple.getTplOrigin();
      float tplHeight=triple.getTplSize();
      float translationY=triple.getTranslation();
      PdfTemplate templateWhole=contentByte.createTemplate(tplWidth,tplHeight);
      templateWhole.addImage(img,imageWidth,0,0,imageHeight,translationX,translationY);
      contentByte.addTemplate(templateWhole,tplOriginX,tplOrininY);
    }
 else     if (BackgroundImageInfo.REPEAT_X == repeat) {
      float remainX=width;
      PdfTemplate template=null;
      if (width > imageWidth) {
        if (height - absPosY > imageHeight) {
          template=contentByte.createTemplate(imageWidth,imageHeight);
          template.addImage(img,imageWidth,0,0,imageHeight,0,0);
        }
 else {
          template=contentByte.createTemplate(imageWidth,height);
          template.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + height);
        }
      }
      while (remainX > 0) {
        if (remainX < imageWidth) {
          if (height - absPosY > imageHeight) {
            PdfTemplate templateX=contentByte.createTemplate(remainX,imageHeight);
            templateX.addImage(img,imageWidth,0,0,imageHeight,0,0);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - imageHeight);
          }
 else {
            PdfTemplate templateX=contentByte.createTemplate(remainX,height);
            templateX.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + height - absPosY);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - height);
          }
          remainX=0;
        }
 else {
          if (height - absPosY > imageHeight)           contentByte.addTemplate(template,x + width - remainX,y - absPosY - imageHeight);
 else           contentByte.addTemplate(template,x + width - remainX,y - absPosY - height);
          remainX-=imageWidth;
        }
      }
    }
 else     if (BackgroundImageInfo.REPEAT_Y == repeat) {
      float remainY=height;
      PdfTemplate template=null;
      if (height > imageHeight) {
        template=contentByte.createTemplate(width - absPosX > imageWidth ? imageWidth : width - absPosX,imageHeight);
        template.addImage(img,imageWidth,0,0,imageHeight,0,0);
      }
      while (remainY > 0) {
        if (remainY < imageHeight) {
          PdfTemplate templateY=contentByte.createTemplate(width - absPosX > imageWidth ? imageWidth : width - absPosX,remainY);
          templateY.addImage(img,width > imageWidth ? imageWidth : width - absPosX,0,0,imageHeight,0,-(imageHeight - remainY));
          contentByte.addTemplate(templateY,x + absPosX,y - height);
          remainY=0;
        }
 else {
          contentByte.addTemplate(template,x + absPosX,y - height + remainY - imageHeight);
          remainY-=imageHeight;
        }
      }
    }
 else     if (BackgroundImageInfo.REPEAT == repeat) {
      float remainX=width;
      float remainY=height;
      PdfTemplate template=null;
      if (width >= imageWidth && height >= imageHeight) {
        template=contentByte.createTemplate(imageWidth,imageHeight);
        template.addImage(img,imageWidth,0,0,imageHeight,0,0);
      }
      while (remainY > 0) {
        remainX=width;
        if (remainY < imageHeight) {
          while (remainX > 0) {
            if (remainX < imageWidth) {
              PdfTemplate templateXY=contentByte.createTemplate(remainX,remainY);
              templateXY.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + remainY);
              contentByte.addTemplate(templateXY,x + width - remainX,y - height);
              remainX=0;
            }
 else {
              PdfTemplate templateY=contentByte.createTemplate(imageWidth,remainY);
              templateY.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + remainY);
              contentByte.addTemplate(templateY,x + width - remainX,y - height);
              remainX-=imageWidth;
            }
          }
          remainY=0;
        }
 else {
          while (remainX > 0) {
            if (remainX < imageWidth) {
              PdfTemplate templateX=contentByte.createTemplate(remainX,imageHeight);
              templateX.addImage(img,imageWidth,0,0,imageHeight,0,0);
              contentByte.addTemplate(templateX,x + width - remainX,y - height + remainY - imageHeight);
              remainX=0;
            }
 else {
              contentByte.addTemplate(template,x + width - remainX,y - height + remainY - imageHeight);
              remainX-=imageWidth;
            }
          }
          remainY-=imageHeight;
        }
      }
    }
  }
 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();
}

Fixed version (ground truth):
protected void drawBackgroundImage(float x,float y,float width,float height,float iWidth,float iHeight,int repeat,String imageUrl,float absPosX,float absPosY) throws IOException {
  y=transformY(y);
  contentByte.saveState();
  try {
    Image img=null;
    try {
      img=Image.getInstance(new URL(imageUrl));
    }
 catch (    IOException e) {
      if (SvgFile.isSvg(imageUrl)) {
        try {
          img=Image.getInstance(SvgFile.transSvgToArray(imageUrl));
        }
 catch (        IOException ex) {
          throw ex;
        }
      }
 else {
        throw e;
      }
    }
    float imageWidth=iWidth;
    float imageHeight=iHeight;
    if (imageHeight == 0 || imageWidth == 0) {
      int resolutionX=img.getDpiX();
      int resolutionY=img.getDpiY();
      if (0 == resolutionX || 0 == resolutionY) {
        resolutionX=96;
        resolutionY=96;
      }
      imageWidth=img.plainWidth() / resolutionX * 72;
      imageHeight=img.plainHeight() / resolutionY * 72;
    }
    if (BackgroundImageInfo.NO_REPEAT == repeat) {
      TplValueTriple triple=computeTplHorizontalValPair(absPosX,x,width,imageWidth);
      float tplOriginX=triple.getTplOrigin();
      float tplWidth=triple.getTplSize();
      float translationX=triple.getTranslation();
      triple=computeTplVerticalValTriple(absPosY,y,height,imageHeight);
      float tplOrininY=triple.getTplOrigin();
      float tplHeight=triple.getTplSize();
      float translationY=triple.getTranslation();
      PdfTemplate templateWhole=contentByte.createTemplate(tplWidth,tplHeight);
      templateWhole.addImage(img,imageWidth,0,0,imageHeight,translationX,translationY);
      contentByte.addTemplate(templateWhole,tplOriginX,tplOrininY);
    }
 else     if (BackgroundImageInfo.REPEAT_X == repeat) {
      float remainX=width;
      PdfTemplate template=null;
      if (width > imageWidth) {
        if (height - absPosY > imageHeight) {
          template=contentByte.createTemplate(imageWidth,imageHeight);
          template.addImage(img,imageWidth,0,0,imageHeight,0,0);
        }
 else {
          template=contentByte.createTemplate(imageWidth,height);
          template.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + height);
        }
      }
      while (remainX > 0) {
        if (remainX <= imageWidth) {
          if (height - absPosY >= imageHeight) {
            PdfTemplate templateX=contentByte.createTemplate(remainX,imageHeight);
            templateX.addImage(img,imageWidth,0,0,imageHeight,0,0);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - imageHeight);
          }
 else {
            PdfTemplate templateX=contentByte.createTemplate(remainX,height);
            templateX.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + height - absPosY);
            contentByte.addTemplate(templateX,x + width - remainX,y - absPosY - height);
          }
          remainX=0;
        }
 else {
          if (height - absPosY > imageHeight)           contentByte.addTemplate(template,x + width - remainX,y - absPosY - imageHeight);
 else           contentByte.addTemplate(template,x + width - remainX,y - absPosY - height);
          remainX-=imageWidth;
        }
      }
    }
 else     if (BackgroundImageInfo.REPEAT_Y == repeat) {
      float remainY=height;
      PdfTemplate template=null;
      if (height > imageHeight) {
        template=contentByte.createTemplate(width - absPosX > imageWidth ? imageWidth : width - absPosX,imageHeight);
        template.addImage(img,imageWidth,0,0,imageHeight,0,0);
      }
      while (remainY > 0) {
        if (remainY < imageHeight) {
          PdfTemplate templateY=contentByte.createTemplate(width - absPosX > imageWidth ? imageWidth : width - absPosX,remainY);
          templateY.addImage(img,width > imageWidth ? imageWidth : width - absPosX,0,0,imageHeight,0,-(imageHeight - remainY));
          contentByte.addTemplate(templateY,x + absPosX,y - height);
          remainY=0;
        }
 else {
          contentByte.addTemplate(template,x + absPosX,y - height + remainY - imageHeight);
          remainY-=imageHeight;
        }
      }
    }
 else     if (BackgroundImageInfo.REPEAT == repeat) {
      float remainX=width;
      float remainY=height;
      PdfTemplate template=null;
      if (width >= imageWidth && height >= imageHeight) {
        template=contentByte.createTemplate(imageWidth,imageHeight);
        template.addImage(img,imageWidth,0,0,imageHeight,0,0);
      }
      while (remainY > 0) {
        remainX=width;
        if (remainY < imageHeight) {
          while (remainX > 0) {
            if (remainX < imageWidth) {
              PdfTemplate templateXY=contentByte.createTemplate(remainX,remainY);
              templateXY.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + remainY);
              contentByte.addTemplate(templateXY,x + width - remainX,y - height);
              remainX=0;
            }
 else {
              PdfTemplate templateY=contentByte.createTemplate(imageWidth,remainY);
              templateY.addImage(img,imageWidth,0,0,imageHeight,0,-imageHeight + remainY);
              contentByte.addTemplate(templateY,x + width - remainX,y - height);
              remainX-=imageWidth;
            }
          }
          remainY=0;
        }
 else {
          while (remainX > 0) {
            if (remainX < imageWidth) {
              PdfTemplate templateX=contentByte.createTemplate(remainX,imageHeight);
              templateX.addImage(img,imageWidth,0,0,imageHeight,0,0);
              contentByte.addTemplate(templateX,x + width - remainX,y - height + remainY - imageHeight);
              remainX=0;
            }
 else {
              contentByte.addTemplate(template,x + width - remainX,y - height + remainY - imageHeight);
              remainX-=imageWidth;
            }
          }
          remainY-=imageHeight;
        }
      }
    }
  }
 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();
}