コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PortableDocument" /> class.
        /// </summary>
        public PortableDocument()
        {
            this.metadata = this.AddObject();
            this.metadata["/CreationDate"] = DateTime.Now;

            this.catalog           = this.AddObject(PdfWriter.ObjectType.Catalog);
            this.pages             = this.AddObject(PdfWriter.ObjectType.Pages);
            this.catalog["/Pages"] = this.pages;

            this.fonts     = new Dictionary <string, object>();
            this.xobjects  = new Dictionary <string, object>();
            this.extgstate = new Dictionary <string, object>();
            this.resources = this.AddObject();

            // See chapter 10.1 - ProcSet is obsolete from version 1.4?
            this.resources["/ProcSet"] = new[] { "/PDF", "/Text", "/ImageB", "/ImageC", "/ImageI" };

            this.resources["/Font"]      = this.fonts;
            this.resources["/XObject"]   = this.xobjects;
            this.resources["/ExtGState"] = this.extgstate;

            this.currentFont     = StandardFonts.Helvetica.GetFont(false, false);
            this.currentFontSize = 12;
        }
コード例 #2
0
 /// <summary>
 /// Sets the current font.
 /// </summary>
 /// <param name="fontName">The font name.</param>
 /// <param name="fontSize">The font size in points.</param>
 /// <param name="bold">Use bold font weight if set to <c>true</c>.</param>
 /// <param name="italic">Use italic style if set to <c>true</c>.</param>
 public void SetFont(string fontName, double fontSize, bool bold = false, bool italic = false)
 {
     this.currentFont     = GetFont(fontName, bold, italic);
     this.currentFontSize = fontSize;
 }