當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。