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


C# Annotation.SetDimensions方法代码示例

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


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

示例1: AddImage


//.........这里部分代码省略.........
                                decodeparms.Put(PdfName.JBIG2GLOBALS, writer.GetReferenceJBIG2Globals(globals));
                                pimage.Put(PdfName.DECODEPARMS, decodeparms);
                            }
                        }
                        PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_INLINE_IMAGE, pimage);
                        foreach (PdfName key in pimage.Keys)
                        {
                            if (!abrev.ContainsKey(key))
                                continue;
                            PdfObject value = pimage.Get(key);
                            String s = abrev[key];
                            content.Append(s);
                            bool check = true;
                            if (key.Equals(PdfName.COLORSPACE) && value.IsArray())
                            {
                                PdfArray ar = (PdfArray) value;
                                if (ar.Size == 4
                                    && PdfName.INDEXED.Equals(ar.GetAsName(0))
                                    && ar.GetPdfObject(1).IsName()
                                    && ar.GetPdfObject(2).IsNumber()
                                    && ar.GetPdfObject(3).IsString()
                                    )
                                {
                                    check = false;
                                }

                            }
                            if (check && key.Equals(PdfName.COLORSPACE) && !value.IsName())
                            {
                                PdfName cs = writer.GetColorspaceName();
                                PageResources prs = PageResources;
                                prs.AddColor(cs, writer.AddToBody(value).IndirectReference);
                                value = cs;
                            }
                            value.ToPdf(null, content);
                            content.Append('\n');
                        }
                        content.Append("ID\n");
                        pimage.WriteContent(content);
                        content.Append("\nEI\nQ").Append_i(separator);
                    }
                    else
                    {
                        PdfName name;
                        PageResources prs = PageResources;
                        Image maskImage = image.ImageMask;
                        if (maskImage != null)
                        {
                            name = writer.AddDirectImageSimple(maskImage);
                            prs.AddXObject(name, writer.GetImageReference(name));
                        }
                        name = writer.AddDirectImageSimple(image);
                        name = prs.AddXObject(name, writer.GetImageReference(name));
                        content.Append(' ').Append(name.GetBytes()).Append(" Do Q").Append_i(separator);
                    }
                }
                if (image.HasBorders())
                {
                    SaveState();
                    float w = image.Width;
                    float h = image.Height;
                    ConcatCTM(a/w, b/w, c/h, d/h, e, f);
                    Rectangle(image);
                    RestoreState();
                }
                if (image.Layer != null)
                    EndLayer();
                Annotation annot = image.Annotation;
                if (annot == null)
                    return;
                double[] r = new double[unitRect.Length];
                for (int k = 0; k < unitRect.Length; k += 2)
                {
                    r[k] = a*unitRect[k] + c*unitRect[k + 1] + e;
                    r[k + 1] = b*unitRect[k] + d*unitRect[k + 1] + f;
                }
                double llx = r[0];
                double lly = r[1];
                double urx = llx;
                double ury = lly;
                for (int k = 2; k < r.Length; k += 2)
                {
                    llx = Math.Min(llx, r[k]);
                    lly = Math.Min(lly, r[k + 1]);
                    urx = Math.Max(urx, r[k]);
                    ury = Math.Max(ury, r[k + 1]);
                }
                annot = new Annotation(annot);
                annot.SetDimensions((float) llx, (float) lly, (float) urx, (float) ury);
                PdfAnnotation an = PdfAnnotationsImp.ConvertAnnotation(writer, annot,
                    new Rectangle((float) llx, (float) lly, (float) urx, (float) ury));
                if (an == null)
                    return;
                AddAnnotation(an);
            } catch (IOException ioe) {
                String path = image != null && image.Url != null ? image.Url.AbsolutePath
                    : MessageLocalization.GetComposedMessage("unknown");
                throw new DocumentException(MessageLocalization.GetComposedMessage("add.image.exception", path), ioe);
            }
        }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:101,代码来源:PdfContentByte.cs

示例2: AddImage


//.........这里部分代码省略.........
     else {
         content.Append("q ");
         content.Append(a).Append(' ');
         content.Append(b).Append(' ');
         content.Append(c).Append(' ');
         content.Append(d).Append(' ');
         content.Append(e).Append(' ');
         content.Append(f).Append(" cm");
         if (inlineImage) {
             content.Append("\nBI\n");
             PdfImage pimage = new PdfImage(image, "", null);
             if (image is ImgJBIG2) {
                 byte[] globals = ((ImgJBIG2)image).GlobalBytes;
                 if (globals != null) {
                     PdfDictionary decodeparms = new PdfDictionary();
                     decodeparms.Put(PdfName.JBIG2GLOBALS, writer.GetReferenceJBIG2Globals(globals));
                     pimage.Put(PdfName.DECODEPARMS, decodeparms);
                 }
             }
             PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_INLINE_IMAGE, pimage);
             foreach (PdfName key in pimage.Keys) {
                 if (!abrev.ContainsKey(key))
                     continue;
                 PdfObject value = pimage.Get(key);
                 String s = abrev[key];
                 content.Append(s);
                 bool check = true;
                 if (key.Equals(PdfName.COLORSPACE) && value.IsArray()) {
                     PdfArray ar = (PdfArray)value;
                     if (ar.Size == 4 
                         && PdfName.INDEXED.Equals(ar.GetAsName(0)) 
                         && ar[1].IsName()
                         && ar[2].IsNumber()
                         && ar[3].IsString()
                     ) {
                         check = false;
                     }
                     
                 }
                 if (check && key.Equals(PdfName.COLORSPACE) && !value.IsName()) {
                     PdfName cs = writer.GetColorspaceName();
                     PageResources prs = PageResources;
                     prs.AddColor(cs, writer.AddToBody(value).IndirectReference);
                     value = cs;
                 }
                 value.ToPdf(null, content);
                 content.Append('\n');
             }
             content.Append("ID\n");
             pimage.WriteContent(content);
             content.Append("\nEI\nQ").Append_i(separator);
         }
         else {
             PdfName name;
             PageResources prs = PageResources;
             Image maskImage = image.ImageMask;
             if (maskImage != null) {
                 name = writer.AddDirectImageSimple(maskImage);
                 prs.AddXObject(name, writer.GetImageReference(name));
             }
             name = writer.AddDirectImageSimple(image);
             name = prs.AddXObject(name, writer.GetImageReference(name));
             content.Append(' ').Append(name.GetBytes()).Append(" Do Q").Append_i(separator);
         }
     }
     if (image.HasBorders()) {
         SaveState();
         float w = image.Width;
         float h = image.Height;
         ConcatCTM(a / w, b / w, c / h, d / h, e, f);
         Rectangle(image);
         RestoreState();
     }
     if (image.Layer != null)
         EndLayer();
     Annotation annot = image.Annotation;
     if (annot == null)
         return;
     float[] r = new float[unitRect.Length];
     for (int k = 0; k < unitRect.Length; k += 2) {
         r[k] = a * unitRect[k] + c * unitRect[k + 1] + e;
         r[k + 1] = b * unitRect[k] + d * unitRect[k + 1] + f;
     }
     float llx = r[0];
     float lly = r[1];
     float urx = llx;
     float ury = lly;
     for (int k = 2; k < r.Length; k += 2) {
         llx = Math.Min(llx, r[k]);
         lly = Math.Min(lly, r[k + 1]);
         urx = Math.Max(urx, r[k]);
         ury = Math.Max(ury, r[k + 1]);
     }
     annot = new Annotation(annot);
     annot.SetDimensions(llx, lly, urx, ury);
     PdfAnnotation an = PdfAnnotationsImp.ConvertAnnotation(writer, annot, new Rectangle(llx, lly, urx, ury));
     if (an == null)
         return;
     AddAnnotation(an);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:101,代码来源:PdfContentByte.cs

示例3: AddImage


//.........这里部分代码省略.........
            if (image.Layer != null)
                BeginLayer(image.Layer);
            if (image.IsImgTemplate()) {
                writer.AddDirectImageSimple(image);
                PdfTemplate template = image.TemplateData;
                float w = template.Width;
                float h = template.Height;
                AddTemplate(template, a / w, b / w, c / h, d / h, e, f);
            }
            else {
                content.Append("q ");
                content.Append(a).Append(' ');
                content.Append(b).Append(' ');
                content.Append(c).Append(' ');
                content.Append(d).Append(' ');
                content.Append(e).Append(' ');
                content.Append(f).Append(" cm");
                if (inlineImage) {
                    content.Append("\nBI\n");
                    PdfImage pimage = new PdfImage(image, "", null);
                    foreach (PdfName key in pimage.Keys) {
                        PdfObject value = pimage.Get(key);
                        String s = (String)abrev[key];
                        if (s == null)
                            continue;
                        content.Append(s);
                        bool check = true;
                        if (key.Equals(PdfName.COLORSPACE) && value.IsArray()) {
                            ArrayList ar = ((PdfArray)value).ArrayList;
                            if (ar.Count == 4
                                && PdfName.INDEXED.Equals(ar[0])
                                && ((PdfObject)ar[1]).IsName()
                                && ((PdfObject)ar[2]).IsNumber()
                                && ((PdfObject)ar[3]).IsString()
                            ) {
                                check = false;
                            }

                        }
                        if (check && key.Equals(PdfName.COLORSPACE) && !value.IsName()) {
                            PdfName cs = writer.GetColorspaceName();
                            PageResources prs = PageResources;
                            prs.AddColor(cs, writer.AddToBody(value).IndirectReference);
                            value = cs;
                        }
                        value.ToPdf(null, content);
                        content.Append('\n');
                    }
                    content.Append("ID\n");
                    pimage.WriteContent(content);
                    content.Append("\nEI\nQ").Append_i(separator);
                }
                else {
                    PdfName name;
                    PageResources prs = PageResources;
                    Image maskImage = image.ImageMask;
                    if (maskImage != null) {
                        name = writer.AddDirectImageSimple(maskImage);
                        prs.AddXObject(name, writer.GetImageReference(name));
                    }
                    name = writer.AddDirectImageSimple(image);
                    name = prs.AddXObject(name, writer.GetImageReference(name));
                    content.Append(' ').Append(name.GetBytes()).Append(" Do Q").Append_i(separator);
                }
            }
            if (image.HasBorders()) {
                SaveState();
                float w = image.Width;
                float h = image.Height;
                ConcatCTM(a / w, b / w, c / h, d / h, e, f);
                Rectangle(image);
                RestoreState();
            }
            if (image.Layer != null)
                EndLayer();
            Annotation annot = image.Annotation;
            if (annot == null)
                return;
            float[] r = new float[unitRect.Length];
            for (int k = 0; k < unitRect.Length; k += 2) {
                r[k] = a * unitRect[k] + c * unitRect[k + 1] + e;
                r[k + 1] = b * unitRect[k] + d * unitRect[k + 1] + f;
            }
            float llx = r[0];
            float lly = r[1];
            float urx = llx;
            float ury = lly;
            for (int k = 2; k < r.Length; k += 2) {
                llx = Math.Min(llx, r[k]);
                lly = Math.Min(lly, r[k + 1]);
                urx = Math.Max(urx, r[k]);
                ury = Math.Max(ury, r[k + 1]);
            }
            annot = new Annotation(annot);
            annot.SetDimensions(llx, lly, urx, ury);
            PdfAnnotation an = PdfAnnotationsImp.ConvertAnnotation(writer, annot, new Rectangle(llx, lly, urx, ury));
            if (an == null)
                return;
            AddAnnotation(an);
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfContentByte.cs


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