ConcatCTM() public méthode

public ConcatCTM ( float a, float b, float c, float d, float e, float f ) : void
a float
b float
c float
d float
e float
f float
Résultat void
 /** Shows a line of text. Only the first line is written.
  * @param canvas where the text is to be written to
  * @param alignment the alignment. It is not influenced by the run direction
  * @param phrase the <CODE>Phrase</CODE> with the text
  * @param x the x reference position
  * @param y the y reference position
  * @param rotation the rotation to be applied in degrees counterclockwise
  * @param runDirection the run direction
  * @param arabicOptions the options for the arabic shaping
  */    
 public static void ShowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions) {
     if (alignment != Element.ALIGN_LEFT && alignment != Element.ALIGN_CENTER
         && alignment != Element.ALIGN_RIGHT)
         alignment = Element.ALIGN_LEFT;
     canvas.SaveState();
     ColumnText ct = new ColumnText(canvas);
     float lly = -1;
     float ury = 2;
     float llx;
     float urx;
     switch (alignment) {
         case Element.ALIGN_LEFT:
             llx = 0;
             urx = 20000;
             break;
         case Element.ALIGN_RIGHT:
             llx = -20000;
             urx = 0;
             break;
         default:
             llx = -20000;
             urx = 20000;
             break;
     }
     if (rotation == 0) {
         llx += x;
         lly += y;
         urx += x;
         ury += y;
     }
     else {
         double alpha = rotation * Math.PI / 180.0;
         float cos = (float)Math.Cos(alpha);
         float sin = (float)Math.Sin(alpha);
         canvas.ConcatCTM(cos, sin, -sin, cos, x, y);
     }
     ct.SetSimpleColumn(phrase, llx, lly, urx, ury, 2, alignment);
     if (runDirection == PdfWriter.RUN_DIRECTION_RTL) {
         if (alignment == Element.ALIGN_LEFT)
             alignment = Element.ALIGN_RIGHT;
         else if (alignment == Element.ALIGN_RIGHT)
             alignment = Element.ALIGN_LEFT;
     }
     ct.Alignment = alignment;
     ct.ArabicOptions = arabicOptions;
     ct.RunDirection = runDirection;
     ct.Go();
     canvas.RestoreState();
 }
 /** Places the barcode in a <CODE>PdfContentByte</CODE>. The
  * barcode is always placed at coodinates (0, 0). Use the
  * translation matrix to move it elsewhere.<p>
  * The bars and text are written in the following colors:<p>
  * <P><TABLE BORDER=1>
  * <TR>
  *   <TH><P><CODE>barColor</CODE></TH>
  *   <TH><P><CODE>textColor</CODE></TH>
  *   <TH><P>Result</TH>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P>bars and text painted with current fill color</TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>barColor</CODE></TD>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P>bars and text painted with <CODE>barColor</CODE></TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>null</CODE></TD>
  *   <TD><P><CODE>textColor</CODE></TD>
  *   <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD>
  *   </TR>
  * <TR>
  *   <TD><P><CODE>barColor</CODE></TD>
  *   <TD><P><CODE>textColor</CODE></TD>
  *   <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD>
  *   </TR>
  * </TABLE>
  * @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed
  * @param barColor the color of the bars. It can be <CODE>null</CODE>
  * @param textColor the color of the text. It can be <CODE>null</CODE>
  * @return the dimensions the barcode occupies
  */
 public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
     if (supp.Font != null)
         supp.BarHeight = ean.BarHeight + supp.Baseline - supp.Font.GetFontDescriptor(BaseFont.CAPHEIGHT, supp.Size);
     else
         supp.BarHeight = ean.BarHeight;
     Rectangle eanR = ean.BarcodeSize;
     cb.SaveState();
     ean.PlaceBarcode(cb, barColor, textColor);
     cb.RestoreState();
     cb.SaveState();
     cb.ConcatCTM(1, 0, 0, 1, eanR.Width + n, eanR.Height - ean.BarHeight);
     supp.PlaceBarcode(cb, barColor, textColor);
     cb.RestoreState();
     return this.BarcodeSize;
 }
Exemple #3
0
 protected override void Draw(PdfContentByte cb)
 {
     //change the coordinate system for all what follows
     //bottom left corner to top right corner
     cb.ConcatCTM(1, 0, 0, -1, -viewBox.Left, height - viewBox.Bottom);
 }
Exemple #4
0
        protected override void Draw(PdfContentByte cb)
        {
            //TODO if width and height not know: what to do
            //PdfTemplate template = cb.CreateTemplate(this.width, this.height);		
            PdfTemplate template = cb.CreateTemplate(500, 500);
            //draw the list of elements on the new template
            foreach (IElement elem in this.list)
            {
                Graphic graphic = (Graphic)elem;

                if (applyCSSToElements)
                {
                    graphic.Draw(template, GetCombinedCss(graphic.GetCss(), GetCss()));
                }
                else
                {
                    graphic.Draw(template, graphic.GetCss());
                }
            }
            //add the template at the x, y position
            System.Drawing.Drawing2D.Matrix translation = new System.Drawing.Drawing2D.Matrix();
            translation.Translate(this.x, this.y);
            cb.ConcatCTM(translation);

            cb.Add(template);
        }
Exemple #5
0
        private void ShowText(PdfContentByte cb, float x, float y, float xPrevious, float yPrevious, double xmidden, double ymidden, String character)
        {
            double corner = CalculateCorner(x, y, xPrevious, yPrevious);
            cb.SaveState();
            PdfTemplate template2 = cb.CreateTemplate(1000, 1000);

            template2.BeginText();
            template2.SetColorFill(BaseColor.BLACK);
            BaseFont bf = BaseFont.CreateFont();
            template2.SetFontAndSize(bf, fontsize);
            //template2.SetTextRise(10);
            //double halfWidthOfCharacter = cb.GetEffectiveStringWidth(character+"", true) / 2.0;  
            template2.SetTextMatrix(0, 0);
            template2.ShowText(character + "");
            template2.EndText();
            Matrix translation = new Matrix();
            translation.Translate((float)xmidden, (float)ymidden);
            cb.ConcatCTM(translation);
            Matrix rotation = new Matrix();
            rotation.Rotate((float)corner);
            cb.ConcatCTM(rotation);
            cb.ConcatCTM(1, 0, 0, -1, 0, 0);
            cb.AddTemplate(template2, 0, 0);
            cb.RestoreState();
        }
Exemple #6
0
        void DrawGroup(PdfContentByte cb)
        {
            //TODO if width and height not know: what to do
            //PdfTemplate template = cb.CreateTemplate(this.width, this.height);		
            PdfTemplate template = cb.CreateTemplate(500, 500);
            //draw the list of elements on the new template

            IList<int> xSpacing = null, ySpacing = null;
            float defaultSpacing = template.CharacterSpacing;
            float rise = 0;

            template.BeginText();
            //
            foreach (IElement elem in this.list)
            {
                Text text = (Text)elem;
                //CssSvgAppliers.GetInstance().ApplyForText(, text.GetCss(), text.GetChunk());
                CssSvgAppliers.GetInstance().ApplyForText(template, text.GetCss(), text.GetChunk());

                if (!text.IsRelative())
                {
                    //when there are x,y coordinates in the text or tspan
                    template.SetTextMatrix(text.GetX(), -1 * text.GetY());
                }

                //System.out.Println(text.chunk.GetFont());

                //the spacing
                if (text.Dx != null)
                {
                    xSpacing = text.Dx;
                }
                if (text.Dy != null)
                {
                    ySpacing = text.Dy;
                    rise = 0;
                }
                if (xSpacing != null || ySpacing != null)
                {
                    String display = text.GetText();
                    for (int i = 0; i < display.Length; i++)
                    {
                        if (xSpacing != null && xSpacing.Count > 0)
                        {
                            template.SetCharacterSpacing(xSpacing[0]);
                            xSpacing.Remove(0);
                        }
                        if (ySpacing != null && ySpacing.Count > 0)
                        {
                            rise = rise - ySpacing[0];
                            template.SetTextRise(rise);
                            ySpacing.Remove(0);
                        }
                        else
                        {
                            template.SetTextRise(rise);
                        }
                        template.ShowText(display.Substring(i, 1));

                        template.SetCharacterSpacing(defaultSpacing);
                    }
                }
                else
                {
                    template.ShowText(text.GetText());
                }
            }
            template.EndText();
            //add the template at the x, y position
            cb.ConcatCTM(1, 0, 0, -1, 0, 0);

            cb.Add(template);
        }
Exemple #7
0
 /** Shows a line of text. Only the first line is written.
  * @param canvas where the text is to be written to
  * @param alignment the alignment. It is not influenced by the run direction
  * @param phrase the <CODE>Phrase</CODE> with the text
  * @param x the x reference position
  * @param y the y reference position
  * @param rotation the rotation to be applied in degrees counterclockwise
  * @param runDirection the run direction
  * @param arabicOptions the options for the arabic shaping
  */
 public static void ShowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions)
 {
     if (alignment != Element.ALIGN_LEFT && alignment != Element.ALIGN_CENTER
     && alignment != Element.ALIGN_RIGHT)
     alignment = Element.ALIGN_LEFT;
     canvas.SaveState();
     ColumnText ct = new ColumnText(canvas);
     if (rotation == 0) {
     if (alignment == Element.ALIGN_LEFT)
         ct.SetSimpleColumn(phrase, x, y - 1, 20000 + x, y + 2, 2, alignment);
     else if (alignment == Element.ALIGN_RIGHT)
         ct.SetSimpleColumn(phrase, x-20000, y-1, x, y+2, 2, alignment);
     else
         ct.SetSimpleColumn(phrase, x-20000, y-1, x+20000, y+2, 2, alignment);
     }
     else {
     double alpha = rotation * Math.PI / 180.0;
     float cos = (float)Math.Cos(alpha);
     float sin = (float)Math.Sin(alpha);
     canvas.ConcatCTM(cos, sin, -sin, cos, x, y);
     if (alignment == Element.ALIGN_LEFT)
         ct.SetSimpleColumn(phrase, 0, -1, 20000, 2, 2, alignment);
     else if (alignment == Element.ALIGN_RIGHT)
         ct.SetSimpleColumn(phrase, -20000, -1, 0, 2, 2, alignment);
     else
         ct.SetSimpleColumn(phrase, -20000, -1, 20000, 2, 2, alignment);
     }
     if (runDirection == PdfWriter.RUN_DIRECTION_RTL) {
     if (alignment == Element.ALIGN_LEFT)
         alignment = Element.ALIGN_RIGHT;
     else if (alignment == Element.ALIGN_RIGHT)
         alignment = Element.ALIGN_LEFT;
     }
     ct.Alignment = alignment;
     ct.ArabicOptions = arabicOptions;
     ct.RunDirection = runDirection;
     ct.Go();
     canvas.RestoreState();
 }