Axional provides a high quality reporting and document publishing library built on top of FOP processing. The DocumentBuilder object provides a mechanism to access the library.

# 1 The page layout

You can generate a simple page layout using DocumentBuilder, creating a SimplePageMaster and adding a PageSequence. By default, each SimplePageMaster has 5 regions:

• Body, the region where content flows
• Before, the region above the body
• After, the region below the body
• Start, the region left to the body
• End, the region right to the body

The following examples will generate a A4 Portrait and A4 Landscape in debug mode so we can see the 5 regions. Notice, margins of 0.5 cm are show white.

Copy

A4 Portrait

<script>
var PAGE_EVEN = "Page";

// ====================================================================
// Document layout: single page, 0.5 margins, A4 Portrait
// ====================================================================

var root = new Ax.fop.DocumentBuilder()
.setDebug("*")
.addSimplePageMaster(PAGE_EVEN, new Ax.fop.PageSize("A4"), 0.5, 0.5, 0.5, 0.5)
.build();

// ====================================================================
// GENERATE PDF
// ====================================================================

var fop = root.toFOP();
let pdf = new Ax.fop.Processor().transform(fop);
let doc = new Ax.io.File("/tmp/Regions_A4.pdf");
doc.write(pdf);
return pdf;

</script>
Copy

A4 Landscape

<script>
var PAGE_EVEN = "Page";

// ====================================================================
// Document layout: single page, 0.5 margins, A4 Landscape
// ====================================================================

var root = new Ax.fop.DocumentBuilder()
.setDebug("*")
.addPageMaster(PAGE_EVEN, new Ax.fop.PageSize("A4").rotate, 0.5, 0.5, 0.5, 0.5)
.build();

// ====================================================================
// GENERATE PDF
// ====================================================================

var fop = root.toFOP();
let pdf = new Ax.fop.Processor().transform(fop);
let doc = new Ax.io.File("/tmp/Regions_A4_Landscape.pdf");
doc.write(pdf);
return pdf;

</script>

# 2 Element containers

## 2.1 Wrapper

#### TO DO

This section is incomplete and will be concluded as soon as possible.

## 2.2 Block

#### TO DO

This section is incomplete and will be concluded as soon as possible.

## 2.3 BlockContainer

#### TO DO

This section is incomplete and will be concluded as soon as possible.

Example

Copy
var bc = before.addBlockContainer().setPosition("absolute")
.setTop("2cm").setLeft("3cm").setWidth("1cm").setHeight("1.5cm")
.setBorderColor("red").setBorderStyle("solid").setBorderWidth("3pt")
.addBlock("Second Line");

## 2.4 Inline

#### TO DO

This section is incomplete and will be concluded as soon as possible.

## 2.5 Table

#### TO DO

This section is incomplete and will be concluded as soon as possible.

# 3 Inline html tags

To simplify document writing you can inline a font html style tags to force the render to select font properties using inlining.

Tag Inline substitution by
<b> font-weight='bold'
<i> font-style='italic'
<ul> text-decoration='underline'
<sup> vertical-align='sup' baseline-shift='3pt' font-size='7'
<sub> vertical-align='sub' baseline-shift='-3pt' font-size='7'
<font> You can set any of the following attributes: family, selection-strategy, size, stretch, style, variant, weight

# 4 Unicode chars

You can write an unicode characer using the unicode escape representation \u{digits}. The HTML equivalent is not supported as it will be represented as text.

According the font glyphs, you may need to change to an specific font to use a selected unicode glyph. For example, when using a standard font and you require to display symbols, you can switch to Symbol font.

The following two options are equivalent.

Copy
wrapper.addBlock().addLiteral("ML + CC <font family='Symbol'>\u2192</font> BDA");
wrapper.addBlock().addLiteral("ML + CC &#8594; DBA").setFontFamily("Symbol");

Some common used Symbol fonts are:

 Symbol Unicode Html Display Bullet \u2022 • • Left arrow \u02190 ← ← Right arrow \u2192 → → Up arrow \u2191 ↑ → Down arrow \u2193 ↓ ↓

You can see a list of symbols here