paragraphLine.cs :  » PDF » SharpPDF » sharpPDF » Elements » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » PDF » SharpPDF 
SharpPDF » sharpPDF » Elements » paragraphLine.cs
using System;
using System.Text;

using sharpPDF.Exceptions;
using sharpPDF.Enumerators;
using sharpPDF.Fonts;

namespace sharpPDF.Elements{
  /// <summary>
  /// A Class that implements a PDF paragraph's line.
  /// </summary>
  public sealed class paragraphLine : IWritable, ICloneable
  {
    private string _strLine;
    private int _lineLeftMargin;
    private int _lineTopMargin;
    private pdfAbstractFont _fontType;

    /// <summary>
    /// The left margin of the line
    /// </summary>
    public int LineLeftMargin
    {
      get
      {
        return _lineLeftMargin;
      }
    }

    /// <summary>
    /// The top margin of the line
    /// </summary>
    public int LineTopMargin
    {
      get
      {
        return _lineTopMargin;
      }
    }

    /// <summary>
    /// The text of the line
    /// </summary>
    public string StrLine
    {
      get
      {
        return _strLine;
      }
    }

    /// <summary>
    /// Class's constructor
    /// </summary>
    /// <param name="strLine">Text of the line</param>
    /// <param name="lineTopMargin">Top margin</param>
    /// <param name="lineLeftMargin">Left margin</param>
    /// <param name="fontType">Font Type</param>
    public paragraphLine(string strLine, int lineTopMargin, int lineLeftMargin, pdfAbstractFont fontType)
    {
      _strLine = strLine;
      _lineTopMargin = lineTopMargin;
      _lineLeftMargin = lineLeftMargin;
      _fontType = fontType;
    }

    /// <summary>
    /// Method that returns the PDF codes to write the paragraph's line in the document
    /// </summary>
    /// <returns>String that contains PDF codes</returns>
    public string getText()
    {
      StringBuilder resultString = new StringBuilder();      
      resultString.Append(_lineLeftMargin.ToString() + " -"+ _lineTopMargin.ToString() + " Td" + Convert.ToChar(13) + Convert.ToChar(10));
      if (_fontType is pdfTrueTypeFont) {        
        resultString.Append("(" + textAdapter.checkText(_fontType.encodeText(_strLine)) + ") Tj" + Convert.ToChar(13) + Convert.ToChar(10));
      } else {
        resultString.Append("(" + _fontType.encodeText(textAdapter.checkText(_strLine)) + ") Tj" + Convert.ToChar(13) + Convert.ToChar(10));        
      }      
      resultString.Append("-" + _lineLeftMargin.ToString().Replace(",",".") + " 0 Td" + Convert.ToChar(13) + Convert.ToChar(10));      
      return resultString.ToString();
    }

    #region ICloneable

    /// <summary>
    /// Method that clones the element
    /// </summary>
    /// <returns>Cloned object</returns>
    public object Clone() {
      return new paragraphLine((string)this._strLine.Clone(), this._lineTopMargin, this._lineLeftMargin, this._fontType);
    }

    #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.