Examples of PdfGState


Examples of com.itextpdf.text.pdf.PdfGState

            cb.closePath();
            cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue());
            if (color.getAlpha() < 255) {
                cb.saveState();
                float alpha = color.getAlpha() / 255f;
                PdfGState gState = new PdfGState();
                gState.setFillOpacity(alpha);
                cb.setGState(gState);
            }
            cb.fill();
            if (color.getAlpha() < 255) {
                cb.restoreState();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfGState

        if (showBox) {
            cb.setRGBColorFill(boxColor.getRed(), boxColor.getGreen(), boxColor.getBlue());
            if (boxColor.getAlpha() < 255) {
                cb.saveState();
                float alpha = boxColor.getAlpha() / 255f;
                PdfGState gState = new PdfGState();
                gState.setFillOpacity(alpha);
                cb.setGState(gState);
            }
            float textWidth = getTextWidth(bf, fontSize, label);
            float textHeight = getTextHeight(bf, fontSize, label);

            //A height of just textHeight seems to be half the text height sometimes
            //BaseFont getAscentPoint and getDescentPoint may be not very precise
            cb.rectangle(x - textWidth / 2f - outlineSize / 2f, -y - outlineSize / 2f - textHeight, textWidth + outlineSize, textHeight * 2f + outlineSize);

            cb.fill();
            if (boxColor.getAlpha() < 255) {
                cb.restoreState();
            }
        }

        cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue());
        float textHeight = getTextHeight(bf, fontSize, label);
        if (outlineSize > 0) {
            cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_STROKE);
            cb.setRGBColorStroke(outlineColor.getRed(), outlineColor.getGreen(), outlineColor.getBlue());
            cb.setLineWidth(outlineSize);
            cb.setLineJoin(PdfContentByte.LINE_JOIN_ROUND);
            cb.setLineCap(PdfContentByte.LINE_CAP_ROUND);
            if (outlineColor.getAlpha() < 255) {
                cb.saveState();
                float alpha = outlineColor.getAlpha() / 255f;
                PdfGState gState = new PdfGState();
                gState.setStrokeOpacity(alpha);
                cb.setGState(gState);
            }
            cb.beginText();
            cb.setFontAndSize(bf, font.getSize());
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfGState

        cb.setRGBColorStroke(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue());
        cb.setLineWidth(borderSize);
        cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue());
        if (alpha < 1f) {
            cb.saveState();
            PdfGState gState = new PdfGState();
            gState.setFillOpacity(alpha);
            gState.setStrokeOpacity(alpha);
            cb.setGState(gState);
        }
        cb.circle(x, -y, size);
        if (borderSize > 0) {
            cb.fillStroke();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfGState

            cb.setRGBColorStroke(color.getRed(), color.getGreen(), color.getBlue());
            cb.setLineWidth(thickness);
            if (color.getAlpha() < 255) {
                cb.saveState();
                float alpha = color.getAlpha() / 255f;
                PdfGState gState = new PdfGState();
                gState.setStrokeOpacity(alpha);
                cb.setGState(gState);
            }
            cb.stroke();
            if (color.getAlpha() < 255) {
                cb.restoreState();
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfGState

            cb.setRGBColorStroke(color.getRed(), color.getGreen(), color.getBlue());
            cb.setLineWidth(thickness);
            if (color.getAlpha() < 255) {
                cb.saveState();
                float alpha = color.getAlpha() / 255f;
                PdfGState gState = new PdfGState();
                gState.setStrokeOpacity(alpha);
                cb.setGState(gState);
            }
            cb.stroke();
            if (color.getAlpha() < 255) {
                cb.restoreState();
View Full Code Here

Examples of com.lowagie.text.pdf.PdfGState

    {
      final double[] mx = new double[6];
      inverse.getMatrix(mx);
      if (currentFillGState != 255)
      {
        PdfGState gs = fillGState[255];
        if (gs == null)
        {
          gs = new PdfGState();
          gs.setFillOpacity(1);
          fillGState[255] = gs;
        }
        cb.setGState(gs);
      }

      cb.addImage(image, (float) mx[0], (float) mx[1], (float) mx[2], (float) mx[3], (float) mx[4], (float) mx[5]);
    }
    catch (Exception ex)
    {
      PdfGraphics2D.logger.error("Failed to draw the image: ", ex);
      // throw new IllegalArgumentException("Failed to draw the image");
    }
    finally
    {
      if (currentFillGState != 255)
      {
        final PdfGState gs = fillGState[currentFillGState];
        cb.setGState(gs);
      }
    }
    return true;
  }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfGState

      if (fill)
      {
        if (alpha != currentFillGState)
        {
          currentFillGState = alpha;
          PdfGState gs = fillGState[alpha];
          if (gs == null)
          {
            gs = new PdfGState();
            gs.setFillOpacity((float) alpha / 255.00f);
            fillGState[alpha] = gs;
          }
          cb.setGState(gs);
        }
        cb.setColorFill(color);
      }
      else
      {
        if (alpha != currentStrokeGState)
        {
          currentStrokeGState = alpha;
          PdfGState gs = strokeGState[alpha];
          if (gs == null)
          {
            gs = new PdfGState();
            gs.setStrokeOpacity((float) alpha / 255.0f);
            strokeGState[alpha] = gs;
          }
          cb.setGState(gs);
        }
        cb.setColorStroke(color);
View Full Code Here

Examples of com.lowagie.text.pdf.PdfGState

   */
  public void drawImage(Image img, Rectangle rect, Rectangle clipRect, float opacity) {
    try {
      template.saveState();
      // opacity
      PdfGState state = new PdfGState();
      state.setFillOpacity(opacity);
      state.setBlendMode(PdfGState.BM_NORMAL);
      template.setGState(state);
      // clipping code
      if (clipRect != null) {
        template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(),
            clipRect.getHeight());
View Full Code Here

Examples of com.lowagie.text.pdf.PdfGState

    return rect.getBottom() + f * rect.getHeight();
  }

  private void setStroke(Color color, float linewidth, float[] dashArray) {
    // Color and transparency
    PdfGState state = new PdfGState();
    state.setStrokeOpacity(color.getAlpha());
    state.setBlendMode(PdfGState.BM_NORMAL);
    template.setGState(state);
    template.setColorStroke(color);
    // linewidth
    template.setLineWidth(linewidth);
    if (dashArray != null) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfGState

    }
  }

  private void setFill(Color color) {
    // Color and transparency
    PdfGState state = new PdfGState();
    state.setFillOpacity(color.getAlpha() / 255f);
    state.setBlendMode(PdfGState.BM_NORMAL);
    template.setGState(state);
    template.setColorFill(color);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.