/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. The image can be placed inline. * @param image the <CODE>Image</CODE> object * @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public virtual void AddImage(Image image, bool inlineImage) { if (!image.HasAbsolutePosition()) throw new DocumentException(MessageLocalization.GetComposedMessage("the.image.must.have.absolute.positioning")); float[] matrix = image.GetMatrix(); matrix[Image.CX] = image.AbsoluteX - matrix[Image.CX]; matrix[Image.CY] = image.AbsoluteY - matrix[Image.CY]; AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage); }
/** * Adds an image to the document. * @param image the <CODE>Image</CODE> to add * @throws PdfException on error * @throws DocumentException on error */ protected internal void Add(Image image) { if (image.HasAbsolutePosition()) { graphics.AddImage(image); pageEmpty = false; return; } // if there isn't enough room for the image on this page, save it for the next page if (currentHeight != 0 && IndentTop - currentHeight - image.ScaledHeight < IndentBottom) { if (!strictImageSequence && imageWait == null) { imageWait = image; return; } NewPage(); if (currentHeight != 0 && IndentTop - currentHeight - image.ScaledHeight < IndentBottom) { imageWait = image; return; } } pageEmpty = false; // avoid endless loops if (image == imageWait) imageWait = null; bool textwrap = (image.Alignment & Image.TEXTWRAP) == Image.TEXTWRAP && (image.Alignment & Image.MIDDLE_ALIGN) != Image.MIDDLE_ALIGN; bool underlying = (image.Alignment & Image.UNDERLYING) == Image.UNDERLYING; float diff = leading / 2; if (textwrap) { diff += leading; } float lowerleft = IndentTop - currentHeight - image.ScaledHeight - diff; float[] mt = image.GetMatrix(); float startPosition = IndentLeft - mt[4]; if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) startPosition = IndentRight - image.ScaledWidth - mt[4]; if ((image.Alignment & Image.MIDDLE_ALIGN) == Image.MIDDLE_ALIGN) startPosition = IndentLeft + ((IndentRight - IndentLeft - image.ScaledWidth) / 2) - mt[4]; if (image.HasAbsoluteX()) startPosition = image.AbsoluteX; if (textwrap) { if (imageEnd < 0 || imageEnd < currentHeight + image.ScaledHeight + diff) { imageEnd = currentHeight + image.ScaledHeight + diff; } if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) { // indentation suggested by Pelikan Stephan indentation.imageIndentRight += image.ScaledWidth + image.IndentationLeft; } else { // indentation suggested by Pelikan Stephan indentation.imageIndentLeft += image.ScaledWidth + image.IndentationRight; } } else { if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) startPosition -= image.IndentationRight; else if ((image.Alignment & Image.MIDDLE_ALIGN) == Image.MIDDLE_ALIGN) startPosition += image.IndentationLeft - image.IndentationRight; else startPosition -= image.IndentationRight; } graphics.AddImage(image, mt[0], mt[1], mt[2], mt[3], startPosition, lowerleft - mt[5]); if (!(textwrap || underlying)) { currentHeight += image.ScaledHeight + diff; FlushLines(); text.MoveText(0, - (image.ScaledHeight + diff)); NewLine(); } }
/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. The image can be placed inline. * @param image the <CODE>Image</CODE> object * @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public virtual void AddImage(Image image, bool inlineImage) { if (!image.HasAbsolutePosition()) throw new DocumentException("The image must have absolute positioning."); float[] matrix = image.Matrix; matrix[Image.CX] = image.AbsoluteX - matrix[Image.CX]; matrix[Image.CY] = image.AbsoluteY - matrix[Image.CY]; AddImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage); }