async function populateImage(doc, x, y, imageOptions) {
  const incrementY = constants.INCREMENT_MAIN_Y;

  if (Array.isArray(imageOptions.data)) {
    /* Images in the array will be placed side by side -- MONTY */
    let runningWidth = x;
    let heighestImage = 0;
    for (let imgNumber = 0; imgNumber < imageOptions.data.length; imgNumber++) {
      const pdfImage = await generatePDFImage(imageOptions.data[imgNumber]);
      const imageWidth = imageOptions.imageRules[imgNumber].width;
      const imageHeight = imageOptions.imageRules[imgNumber].height;
      doc.image(pdfImage, runningWidth, y, {fit: [imageWidth, imageHeight]});
      runningWidth += imageWidth;
      if (heighestImage < imageHeight) {
        heighestImage = imageHeight;
      }
    }
    return doc.docYResponse(y + heighestImage + incrementY);
  } else {
    const isCentered = imageOptions["imageType"] && imageOptions["imageType"] === constants.PDFImageType.CENTER;
    const pdfImage = await generatePDFImage(imageOptions.data);
    const imageWidth = imageOptions.imageRules.width;
    const imageHeight = imageOptions.imageRules.height;
    if (isCentered) {
      x = x + (doc.page.width - imageWidth) / 2 - 20;
    }
    doc.image(pdfImage, x, y, {
      fit: [imageWidth, imageHeight],
    });
    const docIncrementY = populateImageDescriptions(doc, imageOptions, doc.y, x);
    doc = docIncrementY.doc;
    y = doc.y;
    if (docIncrementY.incrementY) {
      y += incrementY;
    }
    return doc.docYResponse(y);
  }
}
// imageDescriptions are currently only available for single images
imageDescriptions are currently only available for single images
imageDescriptions are currently only available for single images
async function populateImage(doc, x, y, imageOptions) {
  const incrementY = constants.INCREMENT_MAIN_Y;
  if (Array.isArray(imageOptions.data)) {
    let runningWidth = x;
    let heighestImage = 0;
    for (let imgNumber = 0; imgNumber < imageOptions.data.length; imgNumber++) {
      const pdfImage = await generatePDFImage(imageOptions.data[imgNumber]);
      const imageWidth = imageOptions.imageRules[imgNumber].width;
      const imageHeight = imageOptions.imageRules[imgNumber].height;
      doc.image(pdfImage, runningWidth, y, {fit: [imageWidth, imageHeight]});
      runningWidth += imageWidth;
      if (heighestImage < imageHeight) {
        heighestImage = imageHeight;
      }
    }
    return doc.docYResponse(y + heighestImage + incrementY);
  } else {
    const isCentered = imageOptions["imageType"] && imageOptions["imageType"] === constants.PDFImageType.CENTER;
    const pdfImage = await generatePDFImage(imageOptions.data);
    const imageWidth = imageOptions.imageRules.width;
    const imageHeight = imageOptions.imageRules.height;
    if (isCentered) {
      x = x + (doc.page.width - imageWidth) / 2 - 20;
    }
    doc.image(pdfImage, x, y, {
      fit: [imageWidth, imageHeight],
    });
    const docIncrementY = populateImageDescriptions(doc, imageOptions, doc.y, x);
    doc = docIncrementY.doc;
    y = doc.y;
    if (docIncrementY.incrementY) {
      y += incrementY;
    }
    return doc.docYResponse(y);
  }
}
async function populateImage ( doc , x , y , imageOptions ) { const incrementY = constants . INCREMENT_MAIN_Y ; if ( Array . isArray ( imageOptions . data ) ) { let runningWidth = x ; let heighestImage = 0 ; for ( let imgNumber = 0 ; imgNumber < imageOptions . data . length ; imgNumber ++ ) { const pdfImage = await generatePDFImage ( imageOptions . data [ imgNumber ] ) ; const imageWidth = imageOptions . imageRules [ imgNumber ] . width ; const imageHeight = imageOptions . imageRules [ imgNumber ] . height ; doc . image ( pdfImage , runningWidth , y , { fit : [ imageWidth , imageHeight ] } ) ; runningWidth += imageWidth ; if ( heighestImage < imageHeight ) { heighestImage = imageHeight ; } } return doc . docYResponse ( y + heighestImage + incrementY ) ; } else { const isCentered = imageOptions [ "imageType" ] && imageOptions [ "imageType" ] === constants . PDFImageType . CENTER ; const pdfImage = await generatePDFImage ( imageOptions . data ) ; const imageWidth = imageOptions . imageRules . width ; const imageHeight = imageOptions . imageRules . height ; if ( isCentered ) { x = x + ( doc . page . width - imageWidth ) / 2 - 20 ; } doc . image ( pdfImage , x , y , { fit : [ imageWidth , imageHeight ] , } ) ; const docIncrementY = populateImageDescriptions ( doc , imageOptions , doc . y , x ) ; doc = docIncrementY . doc ; y = doc . y ; if ( docIncrementY . incrementY ) { y += incrementY ; } return doc . docYResponse ( y ) ; } }
imageDescriptions are currently only available for single images
imageDescriptions are currently only available for single images
/* Images in the array will be placed side by side -- MONTY */