iTextSharp.text.Image.HasAbsolutePosition C# (CSharp) Method

HasAbsolutePosition() public method

Checks if the Images has to be added at an absolute position.
public HasAbsolutePosition ( ) : bool
return bool
        public bool HasAbsolutePosition()
        {
            return !float.IsNaN(absoluteY);
        }

Usage Example

コード例 #1
0
 /**
 * 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.Matrix;
     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();
     }
 }
All Usage Examples Of iTextSharp.text.Image::HasAbsolutePosition