CreateTemplate() публичный Метод

public CreateTemplate ( float width, float height ) : PdfTemplate
width float
height float
Результат PdfTemplate
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
        /// <summary>
        /// A vector checkmark image's definition
        /// </summary>
        /// <param name="contentByte">drawing canvas</param>
        /// <param name="color">fill color</param>
        /// <returns>a vector image</returns>
        public static Image CheckmarkImage(PdfContentByte contentByte, System.Drawing.Color color)
        {
            var template = contentByte.CreateTemplate(260, 260);

            template.MoveTo(38.33889376f, 67.35513328f);
            template.CurveTo(39.90689547f, 67.35509017f, 41.09296342f, 66.03921993f, 41.89711165f, 63.40748424f);
            template.CurveTo(43.50531445f, 58.47289182f, 44.65118131f, 56.00562195f, 45.33470755f, 56.0056459f);
            template.CurveTo(45.85735449f, 56.00562195f, 46.40013944f, 56.41682961f, 46.96305772f, 57.23928802f);
            template.CurveTo(58.2608517f, 75.74384316f, 68.7143666f, 90.71198997f, 78.32362116f, 102.14379168f);
            template.CurveTo(80.81631349f, 105.10443984f, 84.77658911f, 106.58480942f, 90.20445269f, 106.58489085f);
            template.CurveTo(91.49097185f, 106.58480942f, 92.35539361f, 106.46145048f, 92.79773204f, 106.21480444f);
            template.CurveTo(93.23991593f, 105.96799555f, 93.4610547f, 105.65958382f, 93.46113432f, 105.28956447f);
            template.CurveTo(93.4610547f, 104.71379041f, 92.7976618f, 103.58294901f, 91.47094155f, 101.89705463f);
            template.CurveTo(75.95141033f, 82.81670149f, 61.55772504f, 62.66726353f, 48.28984822f, 41.44869669f);
            template.CurveTo(47.36506862f, 39.96831273f, 45.47540199f, 39.22812555f, 42.62081088f, 39.22813992f);
            template.CurveTo(39.72597184f, 39.22812555f, 38.0172148f, 39.35149407f, 37.49457722f, 39.5982407f);
            template.CurveTo(36.12755286f, 40.2150402f, 34.51931728f, 43.36081778f, 32.66987047f, 49.03557823f);
            template.CurveTo(30.57914689f, 55.32711903f, 29.53378743f, 59.27475848f, 29.53381085f, 60.87852533f);
            template.CurveTo(29.53378743f, 62.60558406f, 30.94099884f, 64.27099685f, 33.75542165f, 65.87476369f);
            template.CurveTo(35.48425582f, 66.86164481f, 37.01207517f, 67.35509017f, 38.33889376f, 67.35513328f);

            template.SetRGBColorFill(color.R, color.G, color.B);
            template.Fill();

            var img = Image.GetInstance(template);
            return img;
        }
Пример #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);
        }
Пример #5
0
 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);
 }
Пример #6
0
 private static PdfTemplate PdfFooter(PdfContentByte cb)
 {
     // Create the template and assign height
     PdfTemplate tmpFooter = cb.CreateTemplate(580, 70);
     // Move to the bottom left corner of the template
     tmpFooter.MoveTo(1, 1);
     // Place the footer content
     tmpFooter.Stroke();
     // Begin writing the footer
     tmpFooter.BeginText();
     // Set the font and size
     tmpFooter.SetFontAndSize(_baseFont, 8);
     // Write out details from the payee table
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "De facturen zijn contant betaalbaar te Tielt of op rekeningnummer", cb.PdfWriter.PageSize.Width / 2, 45, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "733-0318587-69 bij KBC of 001-6090654-03 bij BNP Paribas Fortis", cb.PdfWriter.PageSize.Width / 2, 35, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Alle klachten dienen binnen de 24 uren, na de uitgevoerde werken schriftelijk medegedeeld te worden.", cb.PdfWriter.PageSize.Width / 2, 25, 0);
     tmpFooter.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Bij geschillen is enkel de rechtbank van Brugge bevoegd.", cb.PdfWriter.PageSize.Width / 2, 15, 0);
     // End text
     tmpFooter.EndText();
     // Stamp a line above the page footer
     cb.SetLineWidth(0f);
     cb.MoveTo(30, 60);
     cb.LineTo(570, 60);
     cb.Stroke();
     // Return the footer template
     return tmpFooter;
 }
Пример #7
0
        /// <summary>
        /// A vector cross sign image's definition
        /// </summary>
        /// <param name="cb">drawing canvas</param>
        /// <param name="color">fill color</param>
        /// <returns>a vector image</returns>
        public static Image CrossImage(PdfContentByte cb, System.Drawing.Color color)
        {
            var template = cb.CreateTemplate(240, 240);

            template.NewPath();
            template.MoveTo(13.57143f, 76.42857262f);
            template.LineTo(23.57143f, 86.42857262f);
            template.LineTo(48.57143f, 61.42857262f);
            template.LineTo(73.57143f, 86.42857262f);
            template.LineTo(83.57143f, 76.42857262f);
            template.LineTo(58.57143f, 51.42857262f);
            template.LineTo(83.57143f, 26.42857262f);
            template.LineTo(73.57143f, 16.42857262f);
            template.LineTo(48.57143f, 41.42857262f);
            template.LineTo(23.57143f, 16.42857262f);
            template.LineTo(13.57143f, 26.42857262f);
            template.LineTo(38.57143f, 51.42857262f);
            template.ClosePath();

            template.NewPath();
            template.MoveTo(13.57143f, 76.42857262f);
            template.LineTo(23.57143f, 86.42857262f);
            template.LineTo(48.57143f, 61.42857262f);
            template.LineTo(73.57143f, 86.42857262f);
            template.LineTo(83.57143f, 76.42857262f);
            template.LineTo(58.57143f, 51.42857262f);
            template.LineTo(83.57143f, 26.42857262f);
            template.LineTo(73.57143f, 16.42857262f);
            template.LineTo(48.57143f, 41.42857262f);
            template.LineTo(23.57143f, 16.42857262f);
            template.LineTo(13.57143f, 26.42857262f);
            template.LineTo(38.57143f, 51.42857262f);
            template.ClosePath();

            template.NewPath();
            template.MoveTo(13.57143f, 76.42857262f);
            template.LineTo(23.57143f, 86.42857262f);
            template.LineTo(48.57143f, 61.42857262f);
            template.LineTo(73.57143f, 86.42857262f);
            template.LineTo(83.57143f, 76.42857262f);
            template.LineTo(58.57143f, 51.42857262f);
            template.LineTo(83.57143f, 26.42857262f);
            template.LineTo(73.57143f, 16.42857262f);
            template.LineTo(48.57143f, 41.42857262f);
            template.LineTo(23.57143f, 16.42857262f);
            template.LineTo(13.57143f, 26.42857262f);
            template.LineTo(38.57143f, 51.42857262f);
            template.ClosePath();

            template.SetRGBColorFill(color.R, color.G, color.B);
            template.Fill();

            var img = Image.GetInstance(template);
            return img;
        }
Пример #8
0
 internal PdfGraphics(string filename, int width, int height)
 {
     originalWidth = currentWidth = width;
     originalHeight = currentHeight = height;
     document = new Document(new iTextSharp.text.Rectangle(width, height), 50, 50, 50, 50);
     document.AddAuthor("");
     document.AddSubject("");
     try{
         writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
         document.Open();
         content = writer.DirectContent;
         template = topTemplate = content.CreateTemplate(width, height);
         content.AddTemplate(template, 0, 0);
     } catch (DocumentException de){
         throw new IOException(de.Message);
     }
 }
Пример #9
0
 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);
     }
 }
Пример #10
0
// ---------------------------------------------------------------------------    
    /**
     * Creates a template based on a stream of PDF syntax.
     * @param content The direct content
     * @param rect The dimension of the templare
     * @param factor A magnification factor
     * @return A PdfTemplate
     */
    public virtual PdfTemplate CreateTemplate(
      PdfContentByte content, Rectangle rect, int factor)
    {
      PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);
      template.ConcatCTM(factor, 0, 0, factor, 0, 0);
      string hero = Path.Combine(Utility.ResourceText, "hero.txt");
      if (!File.Exists(hero)) {
        throw new ArgumentException(hero + " NOT FOUND!");  
      }    
      var fi = new FileInfo(hero);
      using ( var sr = fi.OpenText() ) {
        while (sr.Peek() >= 0) {
          template.SetLiteral((char) sr.Read());
        }
      }
      return template;
    }    
Пример #11
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
     {
         PrintTime = DateTime.Now;
         baseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
         contentByte = writer.DirectContent;
         template = contentByte.CreateTemplate(50, 50);
     }
     catch (DocumentException de)
     {
         Console.WriteLine("||On OpenDocument||" + de.StackTrace);
     }
     catch (System.IO.IOException ioe)
     {
         Console.WriteLine("||On OpenDocument||" + ioe.StackTrace);
     }
 }
Пример #12
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
         {
             _printTime = DateTime.Now;
             _bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
             _cb = writer.DirectContent;
             _template = _cb.CreateTemplate(50, 50);
         }
         catch (DocumentException de)
         {
         }
         catch (System.IO.IOException ioe)
         {
         }
 }
Пример #13
0
 public void OnOpenDocument(PdfWriter writer, Document document)
 {
     _pageSize = document.PageSize;
     _pdfContent = writer.DirectContent;
     _pdfTemplate = _pdfContent.CreateTemplate(50, 50);
 }
Пример #14
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
     {
         PrintTime = DateTime.Now;
         bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
         cb = writer.DirectContent;
         headerTemplate = cb.CreateTemplate(100, 100);
         footerTemplate = cb.CreateTemplate(50, 50);
     }
     catch (DocumentException de)
     {
         //handle exception here
     }
     catch (System.IO.IOException ioe)
     {
         //handle exception here
     }
 }
Пример #15
0
        public override void OnOpenDocument(PdfWriter writer, Document document)
        {
            cb = writer.DirectContent;
            template = cb.CreateTemplate(50, 50);

            base.OnOpenDocument(writer, document);
        }
Пример #16
0
 // we override the onOpenDocument method
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
     {
         PrintTime = DateTime.Now;
         var fontArial = Tools.Helpers.GetFontPath("arial.ttf");
         bf = BaseFont.CreateFont(fontArial, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
         cb = writer.DirectContent;
         template = cb.CreateTemplate(50, 50);
     }
     catch (DocumentException de)
     {
     }
     catch (System.IO.IOException ioe)
     {
     }
 }
Пример #17
0
		public override void OnOpenDocument(PdfWriter writer, Document document)
		{
			PrintDateTime = DateTime.Now;
			cb = writer.DirectContent;
			template = cb.CreateTemplate(50, 50);
		}
Пример #18
0
 /**
  * @param doc the document
  * @param writer the writer
  */
 public PdfTemplatePipeline(PdfContentByte cb) : base(null) {
     template = cb.CreateTemplate(0, 0);
 }
Пример #19
0
 public void DocumentOpened(PdfWriter writer, IList<SummaryCellData> columnCellsSummaryData)
 {
     _pdfContentByte = writer.DirectContent;
     _template = _pdfContentByte.CreateTemplate(50, 50);
 }
Пример #20
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     _baseFont = BaseFont.CreateFont();
     _pdfContent = writer.DirectContent;
     _pageNumberTemplate = _pdfContent.CreateTemplate(50, 50);
 }
Пример #21
0
        public override void OnOpenDocument(PdfWriter writer, Document document)
        {
            try {

                baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                pdfContentByte = writer.DirectContent;
                pdfTemplate = pdfContentByte.CreateTemplate(50, 50);
            } catch (DocumentException documentException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t documentException \t\t" + documentException.Message;
                log.write(logData);
            } catch (System.IO.IOException ioException) {
                Log log = new Log(LogFileType.TXT, LogType.EXCEPTION);
                string logData = DateTime.Now.ToString() + "\t\t documentException \t\t" + ioException.Message;
                log.write(logData);
            }
        }
Пример #22
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);
        }
Пример #23
0
 /** Creates a template with the barcode.
  * @param cb the <CODE>PdfContentByte</CODE> to create the template. It
  * serves no other use
  * @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 template
  * @see #placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor)
  */    
 public PdfTemplate CreateTemplateWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
     PdfTemplate tp = cb.CreateTemplate(0, 0);
     Rectangle rect = PlaceBarcode(tp, barColor, textColor);
     tp.BoundingBox = rect;
     return tp;
 }
Пример #24
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     m_BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
     m_Cb = writer.DirectContent;
     m_Template = m_Cb.CreateTemplate(80, 80);
 }
Пример #25
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
     {
         PrintTime = DateTime.Now;
         bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
         cb = writer.DirectContent;
         template = cb.CreateTemplate(50, 50);
     }
     catch (DocumentException)
     {
     }
     catch (IOException)
     {
     }
 }
Пример #26
0
        public override void OnOpenDocument(PdfWriter writer, Document document)
        {
            var diezpoint = iTextSharp.text.Utilities.MillimetersToPoints(10);
            try
            {
                bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                cb = writer.DirectContent;
                template = cb.CreateTemplate(50, 50);
                this.HMarginLeft = document.LeftMargin;
                this.HMarginRight = document.RightMargin;
                this.HMarginTop = 1.25F * diezpoint;
                this.HMarginBottom = 0.75f * diezpoint;
                this.ancho = document.PageSize.Width - HMarginLeft - HMarginRight;
                this.alto = document.TopMargin - HMarginTop - HMarginBottom;

            }
            catch (DocumentException de)
            {
            }
            catch (System.IO.IOException ioe)
            {
            }
        }
Пример #27
0
 public NPages(PdfContentByte dc)
 {
     template = dc.CreateTemplate(50, 50);
 }
Пример #28
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();
        }
Пример #29
0
    public override void OnOpenDocument(PdfWriter writer, Document document)
    {
        try
        {
            bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb = writer.DirectContent;
            template = cb.CreateTemplate(100, 100);
        }
        catch //(DocumentException de)
        {

        }
        //catch //(System.IO.IOException ioe)
        //{

        //}
    }
Пример #30
0
 public override void OnOpenDocument(PdfWriter writer, Document document)
 {
     try
     {
         cb = writer.DirectContent;
         template = cb.CreateTemplate(50, 50);
     }
     catch (DocumentException de)
     { }
     catch (IOException io)
     { }
 }