当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Normalize方法代码示例

本文整理汇总了C#中Rectangle.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Normalize方法的具体用法?C# Rectangle.Normalize怎么用?C# Rectangle.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle.Normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBoxSize

        /**
         * Returns the intersection between the crop, trim art or bleed box and the parameter intersectingRectangle.
         * This method returns null when
         * - there is no intersection
         * - any of the above boxes are not defined
         * - the parameter intersectingRectangle is null
         *
         * @param boxName crop, trim, art, bleed
         * @param intersectingRectangle the rectangle that intersects the rectangle associated to the boxName
         * @return the intersection of the two rectangles
         */
        public Rectangle GetBoxSize(String boxName, Rectangle intersectingRectangle) {
            Rectangle pdfRectangle = pdf.GetBoxSize(boxName);

            if ( pdfRectangle == null || intersectingRectangle == null ) { // no intersection
                return null;
            }
            //com.itextpdf.awt.geom.Rectangle
            RectangleJ boxRect = new RectangleJ(pdfRectangle);
            RectangleJ intRect = new RectangleJ(intersectingRectangle);
            RectangleJ outRect = boxRect.Intersection(intRect);

            if (outRect.IsEmpty()) { // no intersection
                return null;
            }

            Rectangle output = new Rectangle(outRect.X, outRect.Y, outRect.X + outRect.Width, outRect.Y + outRect.Height);
            output.Normalize();
            return output;
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:30,代码来源:PdfWriter.cs

示例2: GetFieldPositions

 /**
 * Gets the field box positions in the document. The return is an array of <CODE>float</CODE>
 * multiple of 5. For each of this groups the values are: [page, llx, lly, urx,
 * ury]. The coordinates have the page rotation in consideration.
 * @param name the field name
 * @return the positions or <CODE>null</CODE> if field does not exist
 */
 public float[] GetFieldPositions(String name)
 {
     Item item = GetFieldItem(name);
     if (item == null)
         return null;
     float[] ret = new float[item.Size * 5];
     int ptr = 0;
     for (int k = 0; k < item.Size; ++k) {
         try {
             PdfDictionary wd = item.GetWidget(k);
             PdfArray rect = wd.GetAsArray(PdfName.RECT);
             if (rect == null)
                 continue;
             Rectangle r = PdfReader.GetNormalizedRectangle(rect);
             int page = item.GetPage(k);
             int rotation = reader.GetPageRotation(page);
             ret[ptr++] = page;
             if (rotation != 0) {
                 Rectangle pageSize = reader.GetPageSize(page);
                 switch (rotation) {
                     case 270:
                         r = new Rectangle(
                             pageSize.Top - r.Bottom,
                             r.Left,
                             pageSize.Top - r.Top,
                             r.Right);
                         break;
                     case 180:
                         r = new Rectangle(
                             pageSize.Right - r.Left,
                             pageSize.Top - r.Bottom,
                             pageSize.Right - r.Right,
                             pageSize.Top - r.Top);
                         break;
                     case 90:
                         r = new Rectangle(
                             r.Bottom,
                             pageSize.Right - r.Left,
                             r.Top,
                             pageSize.Right - r.Right);
                         break;
                 }
                 r.Normalize();
             }
             ret[ptr++] = r.Left;
             ret[ptr++] = r.Bottom;
             ret[ptr++] = r.Right;
             ret[ptr++] = r.Top;
         }
         catch {
             // empty on purpose
         }
     }
     if (ptr < ret.Length) {
         float[] ret2 = new float[ptr];
         System.Array.Copy(ret, 0, ret2, 0, ptr);
         return ret2;
     }
     return ret;
 }
开发者ID:JamieMellway,项目名称:iTextSharpLGPL-Monotouch,代码行数:67,代码来源:AcroFields.cs

示例3: ConvertToXObject

     /**
      * Converts an annotation structure item to a Form XObject annotation.
      * @param item the structure item
      * @throws IOException
      */
     virtual protected void ConvertToXObject(StructureObject item) {
         PdfDictionary structElem = item.GetStructElem();
         if (structElem == null)
             return;
         PdfDictionary dict =  item.GetObjAsDict();
         if (dict == null || !dict.CheckType(PdfName.ANNOT))
             return;
         PdfDictionary ap = dict.GetAsDict(PdfName.AP);
         if (ap == null)
             return;
         PdfNumber structParent = dict.GetAsNumber(PdfName.STRUCTPARENT);
         if (structParent == null)
             return;
         PdfStream stream = ap.GetAsStream(PdfName.N);
         if (stream == null)
             return;
         stream.Put(PdfName.STRUCTPARENT, structParent);
         PdfIndirectReference xobjr = ap.GetAsIndirectObject(PdfName.N);
         if (xobjr == null)
             return;
         // remove the annotation from the page
 	    for (int i = 0; i < annots.Length; i++) {
 		    PdfIndirectReference annotref = annots.GetAsIndirectObject(i);
 		    if (item.GetObjRef().Number == annotref.Number) {
 			    annots.Remove(i);
 			    break;
 		    }
 	    }
 	    // replace the existing attributes by a PrintField attribute
         PdfDictionary attribute = new PdfDictionary();
         attribute.Put(PdfName.O, PdfName.PRINTFIELD);
         PdfString description = dict.GetAsString(PdfName.TU);
         if (description == null)
             description = dict.GetAsString(PdfName.T);
         if (PdfName.BTN.Equals(dict.Get(PdfName.FT))) {
             PdfNumber fflags = dict.GetAsNumber(PdfName.FF);
             if (fflags != null) {
                 int ff = fflags.IntValue;
                 if ((ff & PdfFormField.FF_PUSHBUTTON) != 0)
                     attribute.Put(PdfName.ROLE, PdfName.PB);
                 // I don't think the condition below will ever be true
                 if ((ff & PdfFormField.FF_RADIO) != 0)
                     attribute.Put(PdfName.ROLE, PdfName.rb);
                 else
                     attribute.Put(PdfName.ROLE, PdfName.CB);
             }
         }
         else {
             attribute.Put(PdfName.ROLE, PdfName.TV);
         }
         attribute.Put(PdfName.DESC, description);
         // Updating the values of the StructElem dictionary
         PdfString t = structElem.GetAsString(PdfName.T);
         if (t == null || t.ToString().Trim().Length == 0)
             structElem.Put(PdfName.T, dict.GetAsString(PdfName.T));
         structElem.Put(PdfName.A, attribute);
         structElem.Put(PdfName.S, PdfName.P);
         structElem.Put(PdfName.PG, pageref);
       	// Defining a new MCID
        	int mcid = items.ProcessMCID(structParents, item.GetRef());
         LOGGER.Info("Using MCID " + mcid);
         structElem.Put(PdfName.K, new PdfNumber(mcid));
         // removing the annotation from the parent tree
         items.RemoveFromParentTree(structParent);
         // Adding the XObject to the page
         PdfName xobj = new PdfName("XObj" + structParent.IntValue);
         LOGGER.Info("Creating XObject with name " + xobj);
         xobjects.Put(xobj, xobjr);
         PdfArray array = dict.GetAsArray(PdfName.RECT);
         // Getting the position of the annotation
         Rectangle rect = new Rectangle(
             array.GetAsNumber(0).FloatValue, array.GetAsNumber(1).FloatValue,
             array.GetAsNumber(2).FloatValue, array.GetAsNumber(3).FloatValue);
         rect.Normalize();
         // A Do operator is forbidden inside a text block
         if (inText && !btWrite) {
             LOGGER.Debug("Introducing extra ET");
             byte[] bytes = Encoding.ASCII.GetBytes("ET\n");
             baos.Write(bytes, 0, bytes.Length);
             etExtra = true;
         }
 	    // Writing the marked-content sequence with the Do operator
 	    // Note that the position assumes that the CTM wasn't changed in the graphics state
 	    // TODO: do the math if the CTM did change!
         ByteBuffer buf = new ByteBuffer();
         buf.Append("/P <</MCID ");
         buf.Append(mcid);
         buf.Append(">> BDC\n");
         buf.Append("q 1 0 0 1 ");
         buf.Append(rect.Left.ToString(CultureInfo.InvariantCulture));
         buf.Append(" ");
         buf.Append(rect.Bottom.ToString(CultureInfo.InvariantCulture));
         buf.Append(" cm ");
         buf.Append(xobj.GetBytes());
         buf.Append(" Do Q\n");
//.........这里部分代码省略.........
开发者ID:newlysoft,项目名称:itextsharp,代码行数:101,代码来源:MCParser.cs


注:本文中的Rectangle.Normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。