コード例 #1
0
ファイル: RtfWriter2.cs プロジェクト: pixelia-es/RazorPDF2
 /**
  * Sets the page margins
  *
  * @param left The left margin
  * @param right The right margin
  * @param top The top margin
  * @param bottom The bottom margin
  * @return <code>false</code>
  */
 public override bool SetMargins(float left, float right, float top, float bottom)
 {
     rtfDoc.GetDocumentHeader().GetPageSetting().SetMarginLeft((int)(left * RtfElement.TWIPS_FACTOR));
     rtfDoc.GetDocumentHeader().GetPageSetting().SetMarginRight((int)(right * RtfElement.TWIPS_FACTOR));
     rtfDoc.GetDocumentHeader().GetPageSetting().SetMarginTop((int)(top * RtfElement.TWIPS_FACTOR));
     rtfDoc.GetDocumentHeader().GetPageSetting().SetMarginBottom((int)(bottom * RtfElement.TWIPS_FACTOR));
     return(true);
 }
コード例 #2
0
        /// <summary>
        /// Imports a font. The font name is looked up in the RtfDocumentHeader and
        /// then the mapping from original font number to actual font number is added.
        /// </summary>
        /// <param name="fontNr">The original font number.</param>
        /// <param name="fontName">The font name to look up.</param>
        public bool ImportFont(string fontNr, string fontName)
        {
            RtfFont rtfFont = new RtfFont(fontName);

            rtfFont.SetRtfDocument(_rtfDoc);
            _importFontMapping[fontNr] = _rtfDoc.GetDocumentHeader().GetFontNumber(rtfFont).ToString();
            return(true);
        }
コード例 #3
0
 /* (non-Javadoc)
  * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
  */
 public override bool HandleCloseGroup()
 {
     if (this.text.Length > 0)
     {
         Document doc = this.rtfParser.GetDocument();
         if (doc != null)
         {
             if (this.elementName.Equals("author"))
             {
                 doc.AddAuthor(this.text);
             }
             if (this.elementName.Equals("title"))
             {
                 doc.AddTitle(this.text);
             }
             if (this.elementName.Equals("subject"))
             {
                 doc.AddSubject(this.text);
             }
         }
         else
         {
             RtfDocument rtfDoc = this.rtfParser.GetRtfDocument();
             if (rtfDoc != null)
             {
                 if (this.elementName.Equals("author"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (this.elementName.Equals("title"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
                 if (this.elementName.Equals("subject"))
                 {
                     Meta           meta = new Meta(this.elementName, this.text);
                     RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                     rtfDoc.GetDocumentHeader().AddInfoElement(elem);
                 }
             }
         }
         this.SetToDefaults();
     }
     return(true);
 }
コード例 #4
0
 /// <summary>
 /// Sets the font name of this RtfFont.
 /// </summary>
 /// <param name="fontName">The font name to use</param>
 public virtual void SetFontName(string fontName)
 {
     _fontName = fontName;
     if (Document != null)
     {
         _fontNumber = Document.GetDocumentHeader().GetFontNumber(this);
     }
 }
コード例 #5
0
 /**
  * Sets the font name of this RtfFont.
  *
  * @param fontName The font name to use
  */
 public virtual void SetFontName(String fontName)
 {
     this.fontName = fontName;
     if (document != null)
     {
         this.fontNumber = document.GetDocumentHeader().GetFontNumber(this);
     }
 }
コード例 #6
0
 /// <summary>
 /// Sets the RtfDocument this RtfFont belongs to
 /// </summary>
 /// <param name="doc">The RtfDocument to use</param>
 public void SetRtfDocument(RtfDocument doc)
 {
     Document = doc;
     if (Document != null)
     {
         _fontNumber = Document.GetDocumentHeader().GetFontNumber(this);
     }
     if (_color != null)
     {
         _color.SetRtfDocument(Document);
     }
 }
コード例 #7
0
 /**
  * Sets the RtfDocument this RtfFont belongs to
  *
  * @param doc The RtfDocument to use
  */
 public void SetRtfDocument(RtfDocument doc)
 {
     this.document = doc;
     if (document != null)
     {
         this.fontNumber = document.GetDocumentHeader().GetFontNumber(this);
     }
     if (this.color != null)
     {
         this.color.SetRtfDocument(this.document);
     }
 }
コード例 #8
0
        /// <summary>
        /// Constructs a RtfFont from a com.lowagie.text.Font
        /// </summary>
        /// <param name="doc">The RtfDocument this font appears in</param>
        /// <param name="font">The Font to use as a base</param>
        public RtfFont(RtfDocument doc, Font font)
        {
            Document = doc;
            if (font != null)
            {
                if (font is RtfFont)
                {
                    _fontName = ((RtfFont)font).GetFontName();
                    _charset  = ((RtfFont)font).GetCharset();
                }
                else
                {
                    setToDefaultFamily(font.Familyname);
                }
                if (font.BaseFont != null)
                {
                    var fontNames = font.BaseFont.FullFontName;
                    for (var i = 0; i < fontNames.Length; i++)
                    {
                        if (fontNames[i][2].Equals("0"))
                        {
                            _fontName = fontNames[i][3];
                            break;
                        }
                        else if (fontNames[i][2].Equals("1033") || fontNames[i][2].Equals(""))
                        {
                            _fontName = fontNames[i][3];
                        }
                    }
                }
                Size = font.Size;
                SetStyle(font.Style);
                Color = font.Color;
                if (Document != null)
                {
                    _fontNumber = Document.GetDocumentHeader().GetFontNumber(this);
                }
            }
            if (Util.EqualsIgnoreCase(_fontName, "unknown"))
            {
                return;
            }

            if (Document != null)
            {
                SetRtfDocument(Document);
            }
        }
コード例 #9
0
ファイル: RtfFont.cs プロジェクト: miroslavmatysek/itextsharp
        /**
         * Constructs a RtfFont from a com.lowagie.text.Font
         * @param doc The RtfDocument this font appears in
         * @param font The Font to use as a base
         */
        public RtfFont(RtfDocument doc, Font font)
        {
            this.document = doc;
            if (font != null)
            {
                if (font is RtfFont)
                {
                    this.fontName = ((RtfFont)font).GetFontName();
                    this.charset  = ((RtfFont)font).GetCharset();
                }
                else
                {
                    SetToDefaultFamily(font.Familyname);
                }
                if (font.BaseFont != null)
                {
                    String[][] fontNames = font.BaseFont.FullFontName;
                    for (int i = 0; i < fontNames.Length; i++)
                    {
                        if (fontNames[i][2].Equals("0"))
                        {
                            this.fontName = fontNames[i][3];
                            break;
                        }
                        else if (fontNames[i][2].Equals("1033") || fontNames[i][2].Equals(""))
                        {
                            this.fontName = fontNames[i][3];
                        }
                    }
                }
                if (Util.EqualsIgnoreCase(this.fontName, "unknown"))
                {
                    this.fontName = DEFAULT_FONT;
                }
                Size = font.Size;
                SetStyle(font.Style);
                Color = font.Color;
                if (document != null)
                {
                    this.fontNumber = document.GetDocumentHeader().GetFontNumber(this);
                }
            }

            if (document != null)
            {
                SetRtfDocument(document);
            }
        }
コード例 #10
0
 /// <summary>
 /// Set the document.
 /// @since 2.1.3
 /// </summary>
 /// <param name="doc">The RtfDocument</param>
 public void SetDocument(RtfDocument doc)
 {
     Document = doc;
     // get the list number or create a new one adding it to the table
     _listNumber = Document.GetDocumentHeader().GetListNumber(this);
 }
コード例 #11
0
 /// <summary>
 /// Resets the footer
 /// </summary>
 public override void ResetFooter()
 {
     _rtfDoc.GetDocumentHeader().SetFooter(null);
 }