API simplification in release 1.6.0

Dear customers,

Thanks for your consideration.

The API has been simplified in release 1.6.0. The new API is fully compatible with the old API. Some new properties and methods are added to make it easy to generate pdf through API programming. You need not change your former codes but you can try to use the new API to build your new application. Please refer to the API documentation and features demo for more info about the new API.

1. A new method Add() is added to some collections, including Cells,Rows,Segments,Sections.
This method is used to initializes a new instance of the class and add it to the collection.

Then

Row row1 = new Row(table1);
table1.Rows.Add(row1);


can be changed to

Row row1 = table1.Rows.Add();

2. Two new constructors Segment(string) and Segment(string,TextInfo) are added to Segment class.
Segment(string) is used to initialize a new instance of the Segment class with the specified string as it content.
Segment(string,TextInfo) is used to initialize a new instance of the Segment class with the specified content and TextInfo.

Then

Segment segment2 = new Segment(text2);
text2.Segments.Add(segment2);
segment2.Content = “cell2”;


can be changed to

text2.Segments.Add(new Segment(“cell2”));

3. Two new methods Add(string) and Add(string,TextInfo) are added to Cells class.
The Add(string) method is used to initialize a new instance of the Cell class,adds a string to the new Cell object and then add the Cell object to the Cells collection.
The Add(string,TextInfo) method is used to initialize a new instance of the Cell class,adds a string to the new Cell object with specified TextInfo and then add the Cell object to the Cells collection.

Then

Cell cell1 = new Cell(row1);
row1.Cells.Add(cell1);

Text text1 = new Text(section);
cell1.Paragraphs.Add(text1);
Segment segment1 = new Segment(text1);
text1.Segments.Add(segment1);
segment1.Content = “cell1”;


can be changed to

Cell cell1 = row1.Cells.Add(“cell1”);

4. Four new constructors are added to Color class: Color(byte),Color(byte,byte,byte),Color(byte,byte,byte,byte),Color(string).
Color(byte) is used to initialize a new instance of the Color class with gray colorspace.
Color(byte,byte,byte) is used to initialize a new instance of the Color class with RGB colorspace.
Color(byte,byte,byte,byte) is used to initialize a new instance of the Color class with CMYK colorspace.
Color(string) is used to initialize a new instance of the Color class with RGB colorspace and specified color name.

Then

Line l3 = new Line(graph);
l3.GraphInfo.Color.ColorSpaceType = ColorSpaceType.Cmyk;
l3.GraphInfo.Color.CmykColorSpace = new CmykColorSpace();
l3.GraphInfo.Color.CmykColorSpace.C = 0;
l3.GraphInfo.Color.CmykColorSpace.M = 128;
l3.GraphInfo.Color.CmykColorSpace.Y = 64;
l3.GraphInfo.Color.CmykColorSpace.K = 0;


can be changed to

l3.GraphInfo.Color = new Color(0,128,64,0);

5. Five new constructors are added to BorderInfo class: BorderInfo(int),BorderInfo(int,float),BorderInfo(int,float,Color),BorderInfo(int,GraphInfo),BorderInfo(int,Color).
BorderInfo(int) is used to initialize a new instance of the BorderInfo class with specified border sides. For example,BorderInfo((int)(BorderSide.Left | BorderSide.Top)).
BorderInfo(int,float) is used to initialize a new instance of the BorderInfo class with specified border sides and border width.
BorderInfo(int,float,Color) is used to initialize a new instance of the BorderInfo class with specified border sides,border width and border color.
BorderInfo(int,GraphInfo) is used to initialize a new instance of the BorderInfo class with specified border sides and border style.
BorderInfo(int,Color) is used to initialize a new instance of the BorderInfo class with specified border sides and border color.

Then

BorderInfo border2 = new BorderInfo();
GraphInfo graphInfo1 = new GraphInfo();
graphInfo1.Color.ColorSpaceType = ColorSpaceType.Rgb;
graphInfo1.Color.RgbColorSpace = System.Drawing.Color.Red;
border2.Left = border2.Right = border2.Bottom = border2.Top = graphInfo1;
cell2.Border = border2;


can be changed to

cell2.Border = new BorderInfo((int)BorderSide.All,new Color(“red”));

6. Two new constructors Line(float[]) and Line(Graph,float[]) are added to Line class.
Line(float[]) is used to initialize a new instance of the Line class with specified position array.
Line(Graph,float[]) is used to initialize a new instance of the Line class with specified position array and inherit style info from specified Graph object.

Then

Line l1 = new Line(graph);
PositionArray posArr = new PositionArray();
posArr.Length = 4;
posArr[0] = 100;
posArr[1] = 0;
posArr[2] = 300;
posArr[3] = 0;
l1.PositionArray = posArr;


can be changed to

float[] posArr = new float[]{100,0,300,0};
Line l1 = new Line(graph1,posArr);


7. Two new constructors Rectangle(float,float,float,float) and Rectangle(Graph,float,float,float,float) are added to the Graph class.
Rectangle(float,float,float,float) is used to initialize a new instance of the Rectangle class with specified position,width and height.
Rectangle(Graph,float,float,float,float) is used to initialize a new instance of the Rectangle class with specified position,width and height and inherit style info from specified Graph object.

Then

Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(graph);
rectangle.Left = 50;
rectangle.Bottom = 10;
rectangle.Width = 100;
rectangle.Height = 50;


can be changed to:

Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(graph,50,10,100,50);

8. Two new constructors are added to Arc class: Arc(float xPosition,float yPosition,float radius,float alpha,float beta) and Arc(Graph graph,float xPosition,float yPosition,float radius,float alpha,float beta).
Arc(float xPosition,float yPosition,float radius,float alpha,float beta) is used to initialize a new instance of the Arc class with specified arc info.
Arc(Graph graph,float xPosition,float yPosition,float radius,float alpha,float beta) is used to initialize a new instance of the Arc class with specified arc info and inherit style info from specified Graph object.

Then

Arc arc = new Arc(graph);
arc.PositionX = 200;
arc.PositionY = 50;
arc.Radius = 30;
arc.Alpha = 30;
arc.Beta = 90;


can be changed to

Arc arc = new Arc(graph,200,50,30,30,90);

9. Two new constructors are added to Circle class: Circle(float xPosition,float yPosition,float radius) and Circle(Graph graph,float xPosition,float yPosition,float radius).
Circle(float xPosition,float yPosition,float radius) is used to initialize a new instance of the Circle class with specified circle info.
Circle(Graph graph,float xPosition,float yPosition,float radius) is used to initialize a new instance of the Circle class with specified circle info and inherit style info from specified Graph object.

Then

Circle circle = new Circle(graph);
circle.PositionX = 200;
circle.PositionY = 50;
circle.Radius = 30;


can be changed to

Circle circle = new Circle(graph,200,50,30);

10. Two new constructors Curve(float[] positionArr) and Curve(Graph graph,float[] positionArr) are added to Curve class.
Curve(float[] positionArr) is used to initialize a new instance of the Curve class with specified curve’s position info.
Curve(Graph graph,float[] positionArr) is used to initialize a new instance of the Curve class with specified curve’s position info and inherit style info from specified Graph object.

Then

Curve curve = new Curve(graph);
curve.Position1X = 0;
curve.Position1Y = 0;
curve.Position2X = 200;
curve.Position2Y = 80;
curve.Position3X = 300;
curve.Position3Y = 40;
curve.Position4X = 350;
curve.Position4Y = 90;


can be changed to

float[] posArr = new float[]{0,0,200,80,300,40,350,90};
Curve curve = new Curve(graph,posArr);


11. Three new constructors are added to Graph class: Graph(float width,float height),Graph(Section section,float width,float height) and Graph(HeaderFooter hf,float width,float height).
Graph(float width,float height) is used to initialize a new instance of the Curve class with specified curve’s position info.
Graph(Section section,float width,float height) is used to initialize a new instance of the Curve class with specified curve’s position info and inherit common property values from the specified Section object.
Graph(HeaderFooter hf,float width,float height) is used to initialize a new instance of the Curve class with specified curve’s position info and inherit common property values from the specified HeaderFooter object.

Then

Graph graph = new Graph(section);
graph.GraphHeight = 100;
graph.GraphWidth = 400;


can be changed to

Graph graph = new Graph(section,100,400);

12. Four new constructors are added to text class: Text(string content),Text(string content,TextInfo info),Text(Section section,string content) and Text(HeaderFooter hf,string content).
Text(string content) is used to initialize a new instance of the Text class with specified string as the content of it’s first segment.
Text(string content,TextInfo info) is used to initialize a new instance of the Text class with specified text style and specified string as the content of it’s first segment.
Text(Section section,string content) is used to initialize a new instance of the Text class with specified string as the content of it’s first segment and inherit text style info from specified Section object.
Text(HeaderFooter hf,string content) is used to initialize a new instance of the Text class with specified string as the content of it’s first segment and inherit text style info from specified HeaderFooter object.

Then

Text text1 = new Text(section);
Segment segment1 = new Segment(text1);
text1.Segments.Add(segment1);
segment1.Content = “this is text content”;


can be changed to

Text text1 = new Text(section,“this is text content”);

13. The border style has been changed.
The old border style is shown in figure 1.
<color=“black;background-image: url(http://www.aspose.com/Products/Aspose.Pdf/images/forum/OldBorder.jpg);width:545px;height:378px”>

The new border style is shown in figure 2.
<color=“black;background-image: url(http://www.aspose.com/Products/Aspose.Pdf/images/forum/NewBorder.jpg);width:491px;height:328px”>

Table border,row border and cell border is overlaped in the new border style. Table’s padding, row’s margin and padding, cell’s margin is obsolete. Using the new border style, you can set “all” border sides at most times. For example,








cell1









cell2





can be changed to








cell1







cell2





14. Four new properties DefaultCellBorder,DefaultCellTextInfo,DefaultCellPadding and ColumnWidths are added to the Table class.
DefaultCellBorder is used to set the border info of all cells in the table.
DefaultCellTextInfo is used to set the text info of all cells in the table.
DefaultCellPadding is used to set the padding info of all cells in the table.
ColumnWidths is used to set the width of all columns in the table.

Then







cell1









cell2





can be changed to








cell1




cell2






How do I use DefaultCellPadding in XML?

I tried the following example, which throws “Unknown attribute in Table element”:





Dear jurev,

Thanks for your consideration.

I have added support for it. Please download hot fix again.