IbexPDFCreator
DevelopersGuide
Tables
85
Figure15-13:
Tablewithimplicit
rows
row 1 column 1
row 1 column 2
row 2 column 1
row 2 column 2
15.5 Table columns
Thetable-column elementisusedtosetthecolumnwidthandothercharacteristicsofa
table column. A table-column element has an associated column number which
determines which column thetable-column element refers to. Thiscolumn number is
either implied (with the firsttable-column element applying to the first column, the
secondtothenextetc.),orexplicitlysetusingthecolumn-numberattribute.
Asingletable-column element can be used todefinethe style of multiple columnsby
usingthenumber-columns-spannedattribute.
Figure 15-14showstheFOforatable with twotable-column elements,which apply to
thefirstandsecondcolumns.Inthiscasetheysetthecolumnwidths(to30%and70%),
andthegivethesecondcolumnashadedbackground.TheoutputcreatedfromtheFO
appearsinFigure15-15.
Figure15-14:
FOusingtable-column
elements
<table>
<table-column column-width='30%'/>
<table-column column-width='70%'
background-color='#dddddd'/>
<table-body>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 1 column 1</block>
</table-cell>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 1 column 2</block>
</table-cell>
</table-row>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 2 column 1</block>
</table-cell>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 2 column 2</block>
</table-cell>
</table-row>
</table-body>
Figure15-15:
Tablewithdefined
columnwidths
row 1 column 1
row 1 column 2
row 2 column 1
row 2 column 2
Somecellattributessuchasbackgroundcoloraredeterminedusingattributesfromthe
cellitselfandfromtheotherelementsofthetablestructure.Theorderofprecedencein
determining cell characteristics such as background-color is table-celltable-row ,
table-body,table-columnandfinallytable.
15.6 Proportional column widths
Columnscanbeallocatedwidthswhichareproportionaltothewidthsofothercolumns.
Forexample,ifwehavetwocolumnsandwanttogivethefirstcolumntwicethewidth
Enable pdf thumbnails - application software tool:C# PDF Thumbnail Create SDK: Draw thumbnail images for PDF in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
Enable pdf thumbnails - application software tool:VB.NET PDF Thumbnail Create SDK: Draw thumbnail images for PDF in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
86
Tables
of the second, we can specify column widths using the proportional-column-width()
function as shown in Figure 15-16. The total of the values used in the
proportional-column-width()functionsis3(2+1),sothefirstcolumnwillgave2/3ofthe
widthandthesecond1/3.TheoutputfromthisFOappearsinFigure15-17.
Figure15-16:
FOusingproportional
columnwidths
<table>
<table-column
column-width='proportional-column-width(2)'/>
<table-column
column-width='proportional-column-width(1)'
background-color='#dddddd'/>
<table-body>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 1 column 1</block>
</table-cell>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 1 column 2</block>
</table-cell>
</table-row>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 2 column 1</block>
</table-cell>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 2 column 2</block>
</table-cell>
</table-row>
</table-body>
Figure15-17:
Outputfrom
proportionalwidth
example
row 1 column 1
row 1 column 2
row 2 column 1
row 2 column 2
15.7 Spanning columns and rows
The number of columns which a cell spans is set by the number-columns-spanned
attribute.AnexampleFOforthisisshowninFigure15-18.Inthisexamplethefirstcellof
thefirstrowspanstwocolumns.TheoutputfromthisFOappearsinFigure15-19.
Figure15-18:
FOforcellspanning2
columns
<table>
<table-column column-width="30%"/>
<table-column column-width="70%"
background-color="#dddddd"/>
<table-body>
<table-row>
<table-cell border="1pt solid blue" padding="2pt"
number-columns-spanned="2">
<block>row 1 column 1</block>
</table-cell>
</table-row>
<table-row>
<table-cell border="1pt solid blue" padding="2pt">
<block>row 2 column 1</block>
</table-cell>
<table-cell border="1pt solid blue" padding="2pt">
<block>row 2 column 2</block>
</table-cell>
</table-row>
</table-body>
application software tool:VB.NET PDF File Compress Library: Compress reduce PDF size in vb.
Embedded page thumbnails. outputFilePath = Program.RootPath + "\\" 3_optimized.pdf"; 'create optimizing for Monochrome Image 'to enable dowmsampling for
www.rasteredge.com
application software tool:C# PDF File Compress Library: Compress reduce PDF size in C#.net
Embedded page thumbnails. outputFilePath = Program.RootPath + "\\" 3_optimized.pdf"; // create optimizing Monochrome Image -- // to enable downsampling for
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
Tables
87
Figure15-19:
Cellspanningtwo
columns
row 1 column 1
row 2 column 1
row 2 column 2
Thenumberof rowswhich a cell spans is set by thenumber-rows-spanned attribute.
ExampleFOforthisisshowninFigure15-20.Inthisexamplethefirstcellofthefirstrow
spanstworows.TheoutputfromthisFOappearsinFigure15-21.
Figure15-20:
FOforcellspanning
tworows
<table>
<table-column column-width='30%'/>
<table-column column-width='70%'
background-color='#dddddd'/>
<table-body>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'
number-rows-spanned='2'>
<block>row 1 column 1</block>
</table-cell>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 1 column 2</block>
</table-cell>
</table-row>
<table-row>
<table-cell border='1pt solid blue' padding='2pt'>
<block>row 2 column 2</block>
</table-cell>
</table-row>
</table-body>
Figure15-21:
Outputforcell
spanningtworows
row 1 column 1
row 1 column 2
row 2 column 2
15.8 Cell separation
XSL-FOhastwowaysofprocessingthebordersofadjacentcellsdependingonthevalue
oftheborder-collapseattributeonthetable.
Ifborder-collapse="collapse",whichisthedefault,thereisnogapbetweencellsandthe
bordersof adjacentcellsaremerged(or"collapsed")togetasinglebordersharedby
both cells. Therules for combining borders are explained in the XSL-FO specification.
Broadly speaking the widest border will be used. This is called the collapsed border
model.
If border-collapse="separate"adjacentbordersarenotmerged.A gapcanbeinserted
between adjacent borders using the border-spacing attribute. The border-spacing
attribute can have one or two values. If one value is specified (for instance
border-spacing="1mm")the verticalandhorizontalspacing between cellsissettothis
value. If two values are specified separated by a space (for instance
border-spacing='1mm 3mm') thehorizontalseparation isset tothe first value andthe
verticalseparationissettothesecond.Thisiscalledtheseparatedbordermodel.
Thefollowingexamplesuseatablewithonerowcontainingtwocells.Thefirstcellhasa
bottomborder,theseconddoesnot.Thetablealsohasabottomborder.
In the separate border modelthe borderfrom the firstcellwill be drawn before the
borderofthetableasshowninFigure15-22.
application software tool:C# HTML5 PDF Viewer SDK to view, annotate, create and convert PDF
framework class. An advanced PDF editor enable C# users to edit PDF text, image and pages in Visual Studio .NET project. Support to
www.rasteredge.com
application software tool:C# HTML5 PDF Viewer SDK deployment on IIS in .NET
and set the “Physical path” to the place where you store XDoc.PDF.HTML5 Viewer Demo. Pool Defaults…" in the right panel, and set the value "Enable 32-Bit
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
88
Tables
Figure15-22:
Cellswithseparate
borders
this cell has
a bottom
border
this cell does
not have a bottom
border
In the collapsed border model the border from the firstcell will be merged with the
borderofthetableandasingleborderwillbedrawnasshowninFigure15-23.
Figure15-23:
Cellbordercollapsed
withtableborder
this cell has
a bottom
border
this cell does
not have a bottom
border
Ifweaddaninnerbordertoeachcellwecanseethiswiththeseparatemodel,asshown
inFigure15-24.
Figure15-24:
Separatecelland
tableborders
this cell has
a bottom
border
this cell does
not have a
bottom border
Withthecollapsedbordermodeltheborderbetweenthetwocellswillbehalfthewidth
itisintheseparatemodel,asshowninFigure15-25.
Figure15-25:
Collapsedborders
this cell has
a bottom
border
this cell does
not have a bottom
border
Figure 15-26 shows an example of a table with separate borders. Note how the
border-spacing on theprevioustable setsthe spacebetween cellsonly,notthespace
between thecellandthetableborder.Thisspacecan besetusingpadding.If weadd
padding="2mm"tothetablewegetthelayoutshowninFigure15-27.
Figure15-26:
Tablewithseparate
borders
cell one
cell two
cell three
cell four
Figure15-27:
Cellsseparatedfrom
thetablebordersby
padding
cell one
cell two
cell three
cell four
15.9 Table headers
Table headers are created using the table-header element. The table-header should
appear inside the table element after any table-column elements and before any
table-bodyelements.The table-headerelementissimilarinstructuretoa table-body
elementinthatitcontainstable-row elements.
application software tool:VB.NET PDF - VB.NET HTML5 PDF Viewer Deployment on IIS
and set the “Physical path” to the place where you store XDoc.PDF.HTML5 Viewer Demo. Pool Defaults…" in the right panel, and set the value "Enable 32-Bit
www.rasteredge.com
application software tool:C# PDF Page Rotate Library: rotate PDF page permanently in C#.net
Enable batch changing PDF page orientation without other PDF reader control. Support to overwrite PDF and save rotation changes to original PDF file.
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
Tables
89
This section describes the behavior of table headers which do not change. Headers
whichcanhavedifferentcontentondifferentpagesaredescribedlaterinthischapterin
thesectiononcontinuationmarkersonpage91.
Figure 15-28showstheFOforasimpletable with aonerow headerandtwocontent
rows.TheoutputcreatedbytheFOappearsinFigure15-29.
Figure15-28:
Simpletablewith
header
<table>
<table-column column-width="100%"/>
<table-header>
<table-row>
<table-cell border="1pt solid black" padding="5pt">
<block>Heading</block>
</table-cell>
</table-row>
</table-header>
<table-body>
<table-row>
<table-cell border="1pt solid black" padding="5pt">
<block>row 1</block>
</table-cell>
</table-row>
<table-row border="1pt solid black" padding="5pt">
<table-cell>
<block>row 2</block>
</table-cell>
</table-row>
</table-body>
</table>
Figure15-29:
Tablewithsimple
header
Heading
row 1
row 2
Table headersare repeatedatthe topof thetable after each page break. Thisisthe
default. To prevent the table header appearing on pages after the first, specify
table-omit-header-at-break="true"onthetable element.
15.10 Table footers
Tablefootersarecreatedusingthetable-footerelement.Thetable-footershouldappear
insidethetable elementafteranytable-column andtable-headerelementsandbefore
anytable-body elements.Thetable-footerelementissimilarinstructuretoatable-body
elementinthatitcontainstable-row elements.
Itisacommonerrortoplacethetable-footerelementattheendofthetable,afterthe
table-bodyelements.Itmustbeplacedbeforethe table-bodyelementsbecauseIbex
maystartrenderingthetabletoPDFbeforethewholetablehasbeenreadfromtheFO
file.
Thissectiondescribesthebehavioroftablefooterswhichdonotchange.Footerswhich
canhavedifferentcontentondifferentpagesaredescribedlaterin thischapterin the
sectiononcontinuationmarkersonpage91.
application software tool:C# Create PDF from OpenOffice to convert odt, odp files to PDF in
with XDoc.PDF SDK. Enable C#.NET Users to Create PDF OpenOffice Document (Odt, Ods, Odp) from PDF with .NET PDF Library in C# Class.
www.rasteredge.com
application software tool:VB.NET PDF metadata library: add, remove, update PDF metadata in
VB.NET PDF - Read and Write PDF Metadata in VB.NET. Enable VB.NET Users to Read, Write, Edit, Delete and Update PDF Document Metadata in Visual Basic .NET.
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
90
Tables
Figure15-30showstheFOforasimpletablewithaonerowheaderandfooterandtwo
contentrows.TheoutputcreatedbytheFOappearsinFigure15-31.
Figure15-30:
FOforsimpletable
withheaderand
footer
<table>
<table-column column-width="100%"/>
<table-header>
<table-row>
<table-cell border="1pt solid black" padding="5pt">
<block>Heading</block>
</table-cell>
</table-row>
</table-header>
<table-footer>
<table-row>
<table-cell border="1pt solid black" padding="5pt">
<block>Footer</block>
</table-cell>
</table-row>
</table-footer>
<table-body>
<table-row>
<table-cell border="1pt solid black" padding="5pt">
<block>row 1</block>
</table-cell>
</table-row>
<table-row border="1pt solid black" padding="5pt">
<table-cell>
<block>row 2</block>
</table-cell>
</table-row>
</table-body>
</table>
Figure15-31:
Tablewithsimple
headerandfooter
Heading
row 1
row 2
Footer
Tablefootersarerepeatedatthebottomofthetablebeforeeachpagebreak.Thisisthe
default. To prevent the table footer appearing on pages other than the last, specify
table-omit-footer-at-break="true"onthetable element.
15.11 Behavior at page breaks
15.11.1 Repeatingheaders
Table headersare repeatedatthe topof thetable after each page break. Thisisthe
default. To prevent the table header appearing on pages after the first, specify
table-omit-header-at-break="true"onthetable element.
application software tool:VB.NET PDF Text Extract Library: extract text content from PDF
Enable extracting PDF text to another PDF file, and other formats such as TXT and SVG form. OCR text from scanned PDF by working with XImage.OCR SDK.
www.rasteredge.com
application software tool:C# PDF Text Extract Library: extract text content from PDF file in
Enable extracting PDF text to another PDF file, TXT and SVG formats. Support extracting OCR text from PDF by working with XImage.OCR SDK.
www.rasteredge.com
IbexPDFCreator
DevelopersGuide
Tables
91
15.11.2 Repeatingfooters
Tablefootersarerepeatedatthebottomofthetablebeforeeachpagebreak.Thisisthe
default. To prevent the table footer appearing on pages other than the last, specify
table-omit-footer-at-break="true"onthetable element.
15.11.3 Repeatingtableborders
Tablebordersbydefaultdonot repeatat abreakin thetable,sothetopborderofa
table is rendered only on the first page the table is on and the bottom border is
renderedonlyonthelastpage.
Tomake thetable bottomborderrepeatat each pagebreakitisnecessary tospecify
border-after-width.conditionality="retain"onthetableelement.
To make the table top border repeat at each page break it is necessary to specify
border-before-width.conditionality="retain"onthetableelement.
15.12 Table continuation markers
Table continuation markers provide a way of dynamically changing the header and
footeronatablesothatdifferentcontentcanbedisplayedondifferentpages.Atypical
useofthisfeatureistoputthewords"continuedonnextpage"inthefooterofatable
onallpagesexceptthelast.
Hereweexaminehowthe"continuedonnextpage"requirementcanbesatisfiedusing
Ibex.TheapproachtakenbyXSL-FOhastwoparts,implementedusingthemarkerand
retrieve-table-marker elements. First a retrieve-table-marker element is added to the
footer.WhenthePDFiscreatedthiselementwillbereplacedbythecontentsofoneof
the marker elements which has the same class name. The marker element which
appears in the footer depends on the values of the attributes on the
retrieve-table-marker.
The footer for this example is shown in Figure 15-32. As the PDF file is created the
contentsof the markerelementwith marker-class-name ="continued" willbelocated
andinsertedintothetable-footerelement. Thecontentof themarkerelementmustbe
valid FO elements for their location in the table-footer. In this example the retrieved
elementsgodirectlyunderthetable-footerelement,sotheelementsretrievedmustbe
table-rowelements.
Figure15-32:
FOfor
retrieve-table-marker
<table-footer>
<retrieve-table-marker
retrieve-class-name="continued"
retrieve-position-within-table="first-starting"
retrieve-boundary-within-table="page"/>
</table-footer>
Typically,therewillbemorethanonemarkerelementwhichhasthemarker-class-name
="continued". If this is not the case then the footer content will never change. The
retrieve-positionattributespecifieswhichmarkertoretrieve.Inthisexamplewewant
the first marker which appears on the page, so we use retrieve-position =
IbexPDFCreator
DevelopersGuide
92
Tables
"first-starting-within-page".Wealsospecify retrieve-boundary ="table" soanymarker
fromanypartofthetablewhichhasbeenoutputtoPDFcanberetrieved.Otheroptions
aredetailedlaterinthissection.
Conceptually,IbexlooksateveryrowinthetablewhichhasbeenoutputtothePDFfile
(including rowson thecurrentpage), collects all themarkersassociatedwith each of
thoserowsandselectsonetogointothefooter.Markersassociatedwithrowswhich
arenoton eitherthe currentpageor priorpagesarenot considered. Itispossibleto
have a different marker associated with every row in the table. This is useful for
situationssuchaslikerenderingarunningtotal.
Thesecondpartof theprocessistodefineoneormoremarkerelements.Inthiscase
ourmarkerelementsareassociatedwithtable-row elements. Thefirsttable-rowhasa
markerelementwhichspecifiesthe"continuedonnextpage"text.Thecontentsofthis
markerwillberetrievedforallpagesexceptthelast.
Thelastrowof thetablehasanempty markerelement.Thecontentofthis(thatisto
saynorows)willbewhatappearsinthefooteronthelastpageofthetable.Themarker
fromthefirstrowisshowninFigure15-33andthemarkerfromthelastrowisshownin
Figure15-34.
Figure15-33:
FOformarkerinthe
firsttablerow
<table-row>
<marker marker-class-name="continued">
<table-row>
<table-cell>
<block>continued on next page/<block>
</table-cell>
</table-row>
</marker>
<table-cell>
<block>row 1 cell 1 /<block>
</table-cell>
</table-row>
Figure15-34:
FOformarkerinthe
lasttablerow
<table-row>
<marker marker-class-name="continued"/>
<table-cell>
<block>row (last) cell 1 /<block>
</table-cell>
<table-row>
15.13 Aligning columns at the decimal point
Ibex can align the contents of cells in a column on the decimal point by specifying
text-align="." on each fo:table-cell in the column. This can be done explicity on each
fo:table-cell, or to make things easier to maintain it can be done by specifying
text-align="." on the fo:table-column and text-align="from-table-column" on each
fo:table-cell.
Example FO for aligning columnsis shown in Figure 15-35 andthe resulting outputis
showninFigure15-36.
IbexPDFCreator
DevelopersGuide
Tables
93
Figure15-35:
FOfordecimalpoint
alignment
<table font="10pt arial">
<table-column column-width="50%" />
<table-column column-width="50%" text-align="."/>
<table-body>
<table-row>
<table-cell border="1pt solid black" padding="3pt" >
<block>ibexdls</block>
</table-cell>
<table-cell border="1pt solid black" padding="3pt"
text-align="from-table-column()">
<block>499.02</block>
</table-cell>
</table-row>
<table-row>
<table-cell border="1pt solid black" padding="3pt" >
<block>Total</block>
</table-cell>
<table-cell border="1pt solid black" padding="3pt"
text-align="from-table-column()" font-size="18pt">
<block>499.00</block>
</table-cell>
</table-row>
</table-body>
</table>
Figure15-36:
Outputfordecimal
pointalignment
ibexdls
499.02
Total
499.00
94
Tables
Documents you may be interested
Documents you may be interested