Ax.fop.Processor provides a way to interact with Axional FOP microservices servers.

1 transform

Transforms a FOP into a PDF. The functions comes in three flavours

  • transform(String xml)
  • transform(JSFile file)
  • transform(JSBlob file)

The returned object is a byte array.

Example
Copy
let xml =  `<fo:root xmlns:fo='http://www.w3.org/1999/XSL/Format'>
	<fo:layout-master-set>
		<fo:simple-page-master master-name='simpleA4' page-height='29.7cm' page-width='21cm' margin-top='2cm' margin-bottom='2cm' margin-left='2cm' margin-right='2cm'>
			<fo:region-body/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference='simpleA4'>
		<fo:flow flow-name='xsl-region-body'>
			<fo:block font-size='10pt'>
			Hello World
			</fo:block>
		</fo:flow>
	</fo:page-sequence>
</fo:root>`;
let pdf = new Ax.fop.Processor().transform(xml);                
let doc = new Ax.io.File("/tmp/doc.pdf");   
doc.write(pdf);
A byte array containing the PDF bytes

2 getFonts()

Returns an array of maps containing the description of the fonts installed in the system

Example
Copy
let fontList =  new Ax.fop.FOPProcessor().getFonts();                
console.log(fontList)
[
    {"name":"Activa","weight":400.0,"style":"normal","priority":0.0},
    {"name":"Bitstream Cyberbit","weight":400.0,"style":"normal","priority":0.0,"uri":"Cyberbit/Cyberbit.ttf"},
    {"name":"Comic Sans MS","weight":400.0,"style":"italic","priority":0.0,"uri":"Microsoft/comic.ttf"}, 
    ...
]

3 isReady()

Returns whether FOP microservice is properly configured:

Example
Copy
let isReady =  new Ax.fop.FOPProcessor().isReady();                
console.log(isReady)
true

Pass a true parameter to enforce a check to test whether the microservice is available and ready:

Example
Copy
let isReady =  new Ax.fop.FOPProcessor().isReady(true);                
console.log(isReady)
true