Ejemplo n.º 1
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;
    }    
Ejemplo n.º 2
0
        private static PdfTemplate createTemplate(PdfContentByte content, Rectangle rect, int factor)
        {
            PdfTemplate template = content.CreateTemplate(rect.Width, rect.Height);

            template.ConcatCtm(factor, 0, 0, factor, 0, 0);

            var hero = TestUtils.GetTxtPath("hero.txt");

            if (!File.Exists(hero))
            {
                throw new FileNotFoundException($"{hero} NOT FOUND!");
            }
            var fi = new FileInfo(hero);

            using (var sr = fi.OpenText())
            {
                while (sr.Peek() >= 0)
                {
                    template.SetLiteral((char)sr.Read());
                }
            }
            return(template);
        }