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


C# pdf.PdfTemplate类代码示例

本文整理汇总了C#中iTextSharp.text.pdf.PdfTemplate的典型用法代码示例。如果您正苦于以下问题:C# PdfTemplate类的具体用法?C# PdfTemplate怎么用?C# PdfTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PdfTemplate类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImgTemplate

 /// <summary>
 /// Creats an Image from a PdfTemplate.
 /// </summary>
 /// <param name="template">the PdfTemplate</param>
 public ImgTemplate(PdfTemplate template) : base((Uri)null) {
     if (template == null)
         throw new BadElementException(MessageLocalization.GetComposedMessage("the.template.can.not.be.null"));
     if (template.Type == PdfTemplate.TYPE_PATTERN)
         throw new BadElementException(MessageLocalization.GetComposedMessage("a.pattern.can.not.be.used.as.a.template.to.create.an.image"));
     type = Element.IMGTEMPLATE;
     scaledHeight = template.Height;
     this.Top = scaledHeight;
     scaledWidth = template.Width;
     this.Right = scaledWidth;
     TemplateData = template;
     plainWidth = this.Width;
     plainHeight = this.Height;
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:18,代码来源:ImgTemplate.cs

示例2: ImgTemplate

 /// <summary>
 /// Creats an Image from a PdfTemplate.
 /// </summary>
 /// <param name="template">the PdfTemplate</param>
 public ImgTemplate(PdfTemplate template)
     : base((Uri)null)
 {
     if (template == null)
         throw new BadElementException("The template can not be null.");
     if (template.Type == PdfTemplate.TYPE_PATTERN)
         throw new BadElementException("A pattern can not be used as a template to create an image.");
     type = Element.IMGTEMPLATE;
     scaledHeight = template.Height;
     this.Top = scaledHeight;
     scaledWidth = template.Width;
     this.Right = scaledWidth;
     TemplateData = template;
     plainWidth = this.Width;
     plainHeight = this.Height;
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:20,代码来源:ImgTemplate.cs

示例3: PdfFormXObject

     /**
      * Constructs a <CODE>PdfFormXObject</CODE>-object.
      *
      * @param        template        the template
      * @param   compressionLevel    the compression level for the stream
      * @since   2.1.3 (Replacing the existing constructor with param compressionLevel)
      */
 
     internal PdfFormXObject(PdfTemplate template, int compressionLevel) : base() {
         Put(PdfName.TYPE, PdfName.XOBJECT);
         Put(PdfName.SUBTYPE, PdfName.FORM);
         Put(PdfName.RESOURCES, template.Resources);
         Put(PdfName.BBOX, new PdfRectangle(template.BoundingBox));
         Put(PdfName.FORMTYPE, ONE);
         PdfArray matrix = template.Matrix;
         if (template.Layer != null)
             Put(PdfName.OC, template.Layer.Ref);
         if (template.Group != null)
             Put(PdfName.GROUP, template.Group);
         if (matrix == null)
             Put(PdfName.MATRIX, MATRIX);
         else
             Put(PdfName.MATRIX, matrix);
         bytes = template.ToPdf(null);
         Put(PdfName.LENGTH, new PdfNumber(bytes.Length));
         FlateCompress(compressionLevel);
     }
开发者ID:,项目名称:,代码行数:27,代码来源:

示例4: FooterPdfInitialize

        private static void FooterPdfInitialize(PdfWriter writer, Document document, PdfTemplate template, PdfContentByte contentByte, BaseFont baseFont, DateTime PrintTime)
        {
            int pageNumber = writer.PageNumber;
            string footerText = string.Format("Strona {0}{1}", pageNumber, " z ");
            float lenght = baseFont.GetWidthPoint(footerText, textSize);
            Rectangle pageSize = document.PageSize;

            contentByte.SetRGBColorFill(100, 100, 100);
            contentByte.BeginText();
            contentByte.SetFontAndSize(baseFont, textSize);
            contentByte.SetTextMatrix(pageSize.GetLeft(left), pageSize.GetBottom(bottom));
            contentByte.ShowText(footerText);
            contentByte.EndText();
            contentByte.AddTemplate(template, pageSize.GetLeft(left) + lenght, pageSize.GetBottom(bottom));

            contentByte.BeginText();
            contentByte.SetFontAndSize(baseFont, textSize);
            contentByte.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, string.Format("Utworzony: {0}", PrintTime.ToString()), pageSize.GetRight(right), pageSize.GetBottom(bottom), 0);
            contentByte.EndText();
        }
开发者ID:Khaleesy,项目名称:Csharp,代码行数:20,代码来源:PdfFooter.cs

示例5: AddTemplate

 public void AddTemplate(PdfTemplate template, float x, float y, bool tagContent) {
     AddTemplate(template, 1, 0, 0, 1, x, y, tagContent);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:3,代码来源:PdfContentByte.cs

示例6: GetAppearance

        /**
         * Gets the main appearance layer.
         * <p>
         * Consult <A HREF="http://partners.adobe.com/asn/developer/pdfs/tn/PPKAppearances.pdf">PPKAppearances.pdf</A>
         * for further details.
         * @return the main appearance layer
         * @throws DocumentException on error
         */
        public PdfTemplate GetAppearance() {
            if (IsInvisible()) {
                PdfTemplate t = new PdfTemplate(writer);
                t.BoundingBox = new Rectangle(0, 0);
                writer.AddDirectTemplateSimple(t, null);
                return t;
            }
            if (app[0] == null && !reuseAppearance)
                CreateBlankN0();            
            if (app[1] == null && !acro6Layers) {
                PdfTemplate t = app[1] = new PdfTemplate(writer);
                t.BoundingBox = new Rectangle(100, 100);
                writer.AddDirectTemplateSimple(t, new PdfName("n1"));
                t.SetLiteral(questionMark);
            }
            if (app[2] == null) {
                String text;
                if (layer2Text == null) {
                    StringBuilder buf = new StringBuilder();
                    buf.Append("Digitally signed by ");
                    String name = null;
                    CertificateInfo.X509Name x500name = CertificateInfo.GetSubjectFields((X509Certificate)signCertificate);
                    if (x500name != null) {
                        name = x500name.GetField("CN");
                        if (name == null)
                            name = x500name.GetField("E");
                    }
                    if (name == null)
                        name = "";
                    buf.Append(name).Append('\n');
                    buf.Append("Date: ").Append(signDate.ToString("yyyy.MM.dd HH:mm:ss zzz"));
                    if (reason != null)
                        buf.Append('\n').Append(reasonCaption).Append(reason);
                    if (location != null)
                        buf.Append('\n').Append(locationCaption).Append(location);
                    text = buf.ToString();
                }
                else
                    text = layer2Text;
                PdfTemplate t = app[2] = new PdfTemplate(writer);
                t.BoundingBox = rect;
                writer.AddDirectTemplateSimple(t, new PdfName("n2"));
                if (image != null) {
                    if (imageScale == 0) {
                        t.AddImage(image, rect.Width, 0, 0, rect.Height, 0, 0);
                    }
                    else {
                        float usableScale = imageScale;
                        if (imageScale < 0)
                            usableScale = Math.Min(rect.Width / image.Width, rect.Height / image.Height);
                        float w = image.Width * usableScale;
                        float h = image.Height * usableScale;
                        float x = (rect.Width - w) / 2;
                        float y = (rect.Height - h) / 2;
                        t.AddImage(image, w, 0, 0, h, x, y);
                    }
                }
                Font font;
                if (layer2Font == null)
                    font = new Font();
                else
                    font = new Font(layer2Font);
                float size = font.Size;

                Rectangle dataRect = null;
                Rectangle signatureRect = null;

                if (renderingMode == RenderingMode.NAME_AND_DESCRIPTION || 
                    (renderingMode == RenderingMode.GRAPHIC_AND_DESCRIPTION && this.SignatureGraphic != null)) {
                    // origin is the bottom-left
                    signatureRect = new Rectangle(
                        MARGIN, 
                        MARGIN, 
                        rect.Width / 2 - MARGIN,
                        rect.Height - MARGIN);
                    dataRect = new Rectangle(
                        rect.Width / 2 +  MARGIN / 2, 
                        MARGIN, 
                        rect.Width - MARGIN / 2,
                        rect.Height - MARGIN);

                    if (rect.Height > rect.Width) {
                        signatureRect = new Rectangle(
                            MARGIN, 
                            rect.Height / 2, 
                            rect.Width - MARGIN,
                            rect.Height);
                        dataRect = new Rectangle(
                            MARGIN, 
                            MARGIN, 
                            rect.Width - MARGIN,
                            rect.Height / 2 - MARGIN);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: AddDirectTemplateSimple

 /**
 * Adds a template to the document but not to the page resources.
 * @param template the template to add
 * @param forcedName the template name, rather than a generated one. Can be null
 * @return the <CODE>PdfName</CODE> for this template
 */        
 internal PdfName AddDirectTemplateSimple(PdfTemplate template, PdfName forcedName) {
     PdfIndirectReference refa = template.IndirectReference;
     Object[] obj;
     formXObjects.TryGetValue(refa, out obj);
     PdfName name = null;
     if (obj == null) {
         if (forcedName == null) {
             name = new PdfName("Xf" + formXObjectsCounter);
             ++formXObjectsCounter;
         }
         else
             name = forcedName;
         if (template.Type == PdfTemplate.TYPE_IMPORTED) {
             // If we got here from PdfCopy we'll have to fill importedPages
             PdfImportedPage ip = (PdfImportedPage)template;
             PdfReader r = ip.PdfReaderInstance.Reader;
             if (!readerInstances.ContainsKey(r)) {
                 readerInstances[r] = ip.PdfReaderInstance;
             }
             template = null;
         }
         formXObjects[refa] = new Object[]{name, template};
     }
     else
         name = (PdfName)obj[0];
     return name;
 }
开发者ID:,项目名称:,代码行数:33,代码来源:

示例8: AddTemplate

 /**
  * Adds a template to this content.
  *
  * @param template the template
  * @param x the x location of this template
  * @param y the y location of this template
  */
 public void AddTemplate(PdfTemplate template, float x, float y)
 {
     AddTemplate(template, 1, 0, 0, 1, x, y);
 }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:11,代码来源:PdfContentByte.cs

示例9: CheckNoPattern

 /** Throws an error if it is a pattern.
  * @param t the object to check
  */
 internal void CheckNoPattern(PdfTemplate t)
 {
     if (t.Type == PdfTemplate.TYPE_PATTERN)
         throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.use.of.a.pattern.a.template.was.expected"));
 }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:8,代码来源:PdfContentByte.cs

示例10: AddTemplate

 /** Always throws an error. This operation is not allowed.
  * @param template dummy
  * @param a dummy
  * @param b dummy
  * @param c dummy
  * @param d dummy
  * @param e dummy
  * @param f  dummy */    
 public override void AddTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f) {
     ThrowError();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:11,代码来源:PdfImportedPage.cs

示例11: OnOpenDocument

 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     printTime = DateTime.Now;
     string arialuniTff = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
     baseFont = BaseFont.CreateFont(arialuniTff, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
     pdfContent = writer.DirectContent;
     pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
 }
开发者ID:vamelnyk,项目名称:CorporateEmployeeServiceSystem,代码行数:8,代码来源:PrintHeaderFooter.cs

示例12: OnOpenDocument

        public override void OnOpenDocument(PdfWriter writer, Document document)
        {
            total = writer.DirectContent.CreateTemplate(100, 100);
            total.BoundingBox = new Rectangle(-20, -20, 100, 100);

            helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        }
开发者ID:woofwoof88,项目名称:first-place-processing,代码行数:7,代码来源:pdfPrintEnvelopes.ashx.cs

示例13: OnOpenDocument

 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     base.OnOpenDocument(writer, document);
     font = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
     dc = writer.DirectContent;
     tpl = dc.CreateTemplate(50, 50);
 }
开发者ID:stevesloka,项目名称:bvcms,代码行数:7,代码来源:EnrollmentControlResult.cs

示例14: OnOpenDocument

 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     printTime = DateTime.Now;
     baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
     pdfContent = writer.DirectContent;
     pageNumberTemplate = pdfContent.CreateTemplate(50, 50);
 }
开发者ID:huutruongqnvn,项目名称:vnecoo01,代码行数:7,代码来源:PrintHeaderFooter.cs

示例15: PdfGraphics

 public PdfGraphics(Stream stream, int width, int height)
 {
     originalWidth = currentWidth = width;
     originalHeight = currentHeight = height;
     document = new Document(new Rectangle(width, height), 50, 50, 50, 50);
     document.AddAuthor("");
     document.AddSubject("");
     try{
         writer = PdfWriter.GetInstance(document, stream);
         document.Open();
         content = writer.DirectContent;
         template = topTemplate = content.CreateTemplate(width, height);
         content.AddTemplate(template, 0, 0);
     } catch (DocumentException de){
         throw new IOException(de.Message);
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:17,代码来源:PdfGraphics.cs


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