Table of Contents
- Getting Started
- EO.Pdf
- Overview
- Installation and Deployment
- Using HTML to PDF
- Using PDF Creator
- Using PDF Creator
- Getting Started
- Advanced Formatting Techniques
- Interactive Features
- Low Level Content Objects
- Working with Existing PDF Files
- Using in Web Application
- Advanced Topics
- EO.Web
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Style and Style Sheet |
Overview
All appearance settings are defined on AcmStyle object. Each content object exposes Style property that returns an AcmStyle property through which you can change the content's font, color, border, etc.
Style Properties
The following table lists all available style properties. All units are in inch.
Style Property | Type | Remarks | Inheritable |
---|---|---|---|
FontName | string | Get or set the font name. | Yes |
FontSize | float | Get or set the font size in points. A point is 1/72 inch. | Yes |
FontStyle | Nullable<FontStyle> | Get or set the font style such as bold and italic. | Yes |
LineHeight | Nullable<float> | Get or set the minimum height for a line. If the actual line content height is smaller than this value, extra padding will be added to the top and bottom of the line. If the line content height is greater than this value, the actual line height value will be used. | Yes |
Margin | AcmPadding | Get or set the margin values. Margin defines the extra space reserved outside of a content's border. | No |
Padding | AcmPadding | Get or set the padding values. Padding defines the extra space reserved inside a content's border around its child content. | No |
Border | AcmBorder | Get or set the border information. Use this property to draw lines on one or more sides of the contents. | No |
Top | Nullable<float> | Gets or sets the distance between a block content's top edge and the top edge of its containing block's client area. Setting this property causes the block to be floated. This property is only used by a block content. | No |
Left | Nullable<float> | Gets or sets the distance between a block content's left edge and the left edge of its containing block's client area. Setting this property causes the block to be floated. This property is only used by a block content. | No |
Width | Nullable<float> | Gets or sets the block width. Note that a block width defines the distance between the left edge and right edge of a block's client area, which excludes padding, border and margin. This property is only used by a block content. | No |
Height | Nullable<float> |
Gets or sets the block height. Note that a block height defines the distance between the top edge and bottom edge of a block's client area, which excludes padding, border and margin. This property is only used by a block content. This value is suggestive only. If the actual block content height is greater than this value, then the actual content height is used. |
No |
BackgroundColor | System.Drawing.Color | Gets or sets the content's background color. If this property is set, the content fills its background with the given color. The filling area includes padding and border, but excludes margin. | No |
ForegroundColor | System.Drawing.Color | Gets or sets the content's foreground color. This property is used by AcmText as text color. | Yes |
WordSpacing | Nullable<float> | Gets or sets the word spacing for an AcmText object. This property is only used by an AcmText object but can be applied on any parent object because it is inheritable. | Yes |
ParagraphSpacing | Nullable<float> | Gets or sets the extra spacing to be added between paragraphs by an AcmParagraph object. This property is only used by an AcmParagraph object but can be applied on any parent object because it is inheritable. | Yes |
OffsetX | Nullable<float> |
Gets or sets the horizontal offset from an object's final position to its original position. For example, you can use this property to move an image towards the left or right. Setting this property moves the target object only. It does not affect any other contents or alter the output layout.
If an object is also being scaled (for example, a scaled image), this offset is being applied before scaling. |
No |
OffsetY | Nullable<float> | The same as OffsetX but for vertical offset. | No |
HorizontalAlign | Nullable<AcmHorizontalAlign> | Horizontal alignment of the child contents. This property is applied to block content only. | Yes |
VerticalAlign | Nullable<AcmVerticalAlign> | Vertical alignment of the child contents. This property is applied to block content only. | Yes |
Style Sheet
Styles can be applied individually on all target content objects, or can be applied on a separate AcmStyle object and added into an AcmStyleSheet object, then applies to the content object's through its StyleSheet property and StyleName property. This is extremely useful if you wish to apply the same style on many contents objects.
StyleSheet is inheritable, which means setting this property on the root content object is sufficient enough for all child objects to access this style sheet. StyleName on the other hand must be set on each content object that wish to apply a style from the current style sheet.
The following code demonstrates how to use a style sheet:
//Create a style sheet AcmStyleSheet styleSheet = new AcmStyleSheet(); //Create a new style AcmStyle bigFont = new AcmStyle(); bigFont.FontSize = 20f; //Set the style name. A style must have a name before it //can be added into a style sheet bigFont.Name = "big_font"; //Add the style into the style sheet. styleSheet.Add(bigFont); //Create the root content AcmContent root = new AcmContent(); //Assign the style sheet to the root content root.StyleSheet = styleSheet; //text1 uses "big_font", but overrides font name with "Arial" AcmText text1 = new AcmText("one "); text1.StyleName = "big_font"; //text2 uses "big_font" as is AcmText text2 = new AcmText("two "); text2.Style.FontStyle = System.Drawing.FontStyle.Italic; text2.StyleName = "big_font"; //text3 uses default font AcmText text3 = new AcmText("three "); //Add all three text objects into root root.Children.Add(text1); root.Children.Add(text2); root.Children.Add(text3);
The above code displays "one" in Arial with a size of 20 points, displays "two" in Verdana with a size of 20 points and displays "three" with default font and size.
Note that properties set through a content's Style property takes priority over style properties inherited through a style sheet.