CPTAndroidAPI (CustomPowerTool Android Api)  1.26
it.custom.powertool.api.android.CustomXmlAndroidAPI Class Reference

Public Member Functions

 CustomXmlAndroidAPI (Context appContext)
 Initialize class More...
 
String GetAPIVersion ()
 Get current API version More...
 
int SetXmlFileName (String filename) throws CustomXmlException
 Set the name of the xml project file
To be done as the first step, in order to load the project inside the library.
Notes:
This is the name of the project file created with CustomPowerTool (CPT) Editor (it has .xml extension)
In fact, you must initialize CPT library with the project file that you want to print.
More...
 
int SetXmlObjectTag (String tag, String value) throws CustomXmlException
 Set the value of the element specified by tag (format Id.Property)
In the xml file identify an element with the specified tag and overwrite the value with the supplied one.
Notes:
The xml project file contains the description of the layout to print in the form of xml nodes.
Each node is identified by an Id, and has many properties.
You can change the value of a property, and the document will be printed with this new value.
More...
 
String GetXmlObjectTag (String tag) throws CustomXmlException
 Get the value of the element specified by tag (format Id.Property).
In the xml file identify an element with the specified tag and return its value.
Notes:
This is the Get function, while SetXmlObjectTag() is the equivalent Set function. The xml project file contains the description of the layout to print in the form of xml nodes.
Each node is identified by an Id, and has many properties.
You can retrieve (get) the value of a property.
More...
 
int SetXmlObjectFromParamFile (String xmlParameterFileName) throws CustomXmlException
 Create a list of tag/value using the supplied xml parameter file and apply it to the xml project file (see SetXmlObjectTag() for tag/value meaning).
The parameter file must be in the format produced by CPT Editor
Notes:
The xml parameter file is generated by CPT Editor, and has extension ".param.xml".
The xml parameter file contains the description of the "variable" part of the layout to print, in the form of xml nodes.
This file can be interpreted as a subset of the xml project file, containing only the "variable" properties.
Each node is identified by an Id and can have one or more properties.
It can be modifed manually by the user. More...
 
List< CustomXmlDictionaryItemGetXmlTagValListFromParamFile (String xmlParameterFileName) throws CustomXmlException
 Get the list of tag/value from the supplied xml parameter file.
The parameter file must be in the format produced by CPT Editor
Notes:
The xml parameter file is generated by CPT Editor, and has extension ".param.xml".
For a description of the xml parameter file see SetXmlObjectFromParamFile() This function parses the xml parameter file and generates a list of objects, with tag and value. More...
 
void PrintXml (CustomPrinter prnDevice) throws CustomException, CustomXmlException
 Print xml project file (fit to paper width)
Notes:
This function is used to perform the rendering of the xml project and to send it to the printer.
Prerequistes are loding the project (using SetXmlFileName()) and selecting the printer (using CustomAndroidAPI library) More...
 
void PrintXml (CustomPrinter prnDevice, int left_align, int widthOption, int width) throws CustomException,CustomXmlException
 Print xml project file (fit to paper width)
Notes:
This function is used to perform the rendering of the xml project and to send it to the printer.
Prerequistes are loding the project (using SetXmlFileName()) and selecting the printer (using CustomAndroidAPI library) More...
 
void PreviewXml (String filename) throws CustomXmlException
 Get a preview image
Notes:
This function is used to perform the rendering of the xml project and to return a preview bmp image.
Prerequiste is loding the project (using SetXmlFileName()) More...
 
String GetXmlParsingErrors () throws CustomXmlException
 Parse Xml project file performing a syntax/correctness check
Notes:
After a call to SetXmlFileName(), the project is loaded inside the library.
With this function call it is possible to verify if the syntax of the project is correct: in case of syntax error, a message is returned. More...
 
boolean GetXmlFontPropertyBold (String fontname) throws CustomXmlException
 Get bold property for the font identified by fontname.
Prerequiste is loding the project (using SetXmlFileName()) More...
 
boolean GetXmlFontPropertyItalic (String fontname) throws CustomXmlException
 
void Dispose ()
 Close and release all resources used by an instance of the class. More...
 

Constructor & Destructor Documentation

◆ CustomXmlAndroidAPI()

it.custom.powertool.api.android.CustomXmlAndroidAPI.CustomXmlAndroidAPI ( Context  appContext)
inline

Initialize class

Parameters
appContextAndroid context of the calling application

Member Function Documentation

◆ Dispose()

void it.custom.powertool.api.android.CustomXmlAndroidAPI.Dispose ( )
inline

Close and release all resources used by an instance of the class.

◆ GetAPIVersion()

String it.custom.powertool.api.android.CustomXmlAndroidAPI.GetAPIVersion ( )
inline

Get current API version

Returns
current API version

◆ GetXmlFontPropertyBold()

boolean it.custom.powertool.api.android.CustomXmlAndroidAPI.GetXmlFontPropertyBold ( String  fontname) throws CustomXmlException
inline

Get bold property for the font identified by fontname.
Prerequiste is loding the project (using SetXmlFileName())

Parameters
fontnameFont family name
Returns
true if bold property is available, false if bold property is not available
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or in case of missing font

◆ GetXmlFontPropertyItalic()

boolean it.custom.powertool.api.android.CustomXmlAndroidAPI.GetXmlFontPropertyItalic ( String  fontname) throws CustomXmlException
inline

Get italic property for the font identified by fontname.
Prerequiste is loding the project (using SetXmlFileName())

Parameters
fontnameFont family name
Returns
true if italic property is available, false if italic property is not available
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or in case of missing font

◆ GetXmlObjectTag()

String it.custom.powertool.api.android.CustomXmlAndroidAPI.GetXmlObjectTag ( String  tag) throws CustomXmlException
inline

Get the value of the element specified by tag (format Id.Property).
In the xml file identify an element with the specified tag and return its value.
Notes:
This is the Get function, while SetXmlObjectTag() is the equivalent Set function. The xml project file contains the description of the layout to print in the form of xml nodes.
Each node is identified by an Id, and has many properties.
You can retrieve (get) the value of a property.

Example:
This is a part of the xml project file describing a textbox field:
<CustomItem class="text" id="TextBox0">
....
<text>original string</text>
<fontname>Arial</fontname>
<fontsize>8</fontsize>
.....
</CustomItem>

Use: GetXmlObjectTag("TextBox0.text");
It will return "original string".

Parameters
tagXml Tag (in the form Id.Property) to identify an element
Returns
Value of the element identified by tag or null if there is no match
Exceptions
CustomXmlExceptionif parser is not created (project file not opened)

◆ GetXmlParsingErrors()

String it.custom.powertool.api.android.CustomXmlAndroidAPI.GetXmlParsingErrors ( ) throws CustomXmlException
inline

Parse Xml project file performing a syntax/correctness check
Notes:
After a call to SetXmlFileName(), the project is loaded inside the library.
With this function call it is possible to verify if the syntax of the project is correct: in case of syntax error, a message is returned.

Returns
Error information string in case of errors or an empty string in case of success
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or in case of parsing problems

◆ GetXmlTagValListFromParamFile()

List<CustomXmlDictionaryItem> it.custom.powertool.api.android.CustomXmlAndroidAPI.GetXmlTagValListFromParamFile ( String  xmlParameterFileName) throws CustomXmlException
inline

Get the list of tag/value from the supplied xml parameter file.
The parameter file must be in the format produced by CPT Editor
Notes:
The xml parameter file is generated by CPT Editor, and has extension ".param.xml".
For a description of the xml parameter file see SetXmlObjectFromParamFile() This function parses the xml parameter file and generates a list of objects, with tag and value.

Example:
This is a part of a xml parameter file:
....
<CustomParam class="text" id="TextBox1">
<text>new string 1</text>
</CustomParam>

<CustomParam class="text" id="TextBox2">
<text>new string 2</text>
</CustomParam>
.....
A call to GetXmlObjectFromParamFile() will produce a list of objects like this:

{ Tag:"TextBox1.text", Value:"new string 1" }
{ Tag:"TextBox2.text", Value:"new string 2" }

Parameters
xmlParameterFileNameAbsolute file path of xml parameter file
Returns
List of CustomXmlDictionaryItem, each representing a tag/value pair
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or parameter file doesn't exist

◆ PreviewXml()

void it.custom.powertool.api.android.CustomXmlAndroidAPI.PreviewXml ( String  filename) throws CustomXmlException
inline

Get a preview image
Notes:
This function is used to perform the rendering of the xml project and to return a preview bmp image.
Prerequiste is loding the project (using SetXmlFileName())

Parameters
filenameAbsolute file path used to store the preview image. File path should have extension ".png" in order to get a png format image file
Exceptions
CustomXmlExceptionif parser is not created (project file not opened)

◆ PrintXml() [1/2]

void it.custom.powertool.api.android.CustomXmlAndroidAPI.PrintXml ( CustomPrinter  prnDevice) throws CustomException, CustomXmlException
inline

Print xml project file (fit to paper width)
Notes:
This function is used to perform the rendering of the xml project and to send it to the printer.
Prerequistes are loding the project (using SetXmlFileName()) and selecting the printer (using CustomAndroidAPI library)

Parameters
prnDevicePrinting device, as returned by CustomAndroidAPI library
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or printing device is invalid

◆ PrintXml() [2/2]

void it.custom.powertool.api.android.CustomXmlAndroidAPI.PrintXml ( CustomPrinter  prnDevice,
int  left_align,
int  widthOption,
int  width 
) throws CustomException,CustomXmlException
inline

Print xml project file (fit to paper width)
Notes:
This function is used to perform the rendering of the xml project and to send it to the printer.
Prerequistes are loding the project (using SetXmlFileName()) and selecting the printer (using CustomAndroidAPI library)

Parameters
prnDevicePrinting device, as returned by CustomAndroidAPI library
Parameters
left_alignLeft alignment behavior, see PrintImage in CustomAndroidAPI library documentation
Parameters
widthOptionScaling options, see PrintImage in CustomAndroidAPI library documentation
Parameters
widthPrinted image width in pixel/dots in case of "Scale to Width" option selected, see PrintImage in CustomAndroidAPI library documentation
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or printing device is invalid

◆ SetXmlFileName()

int it.custom.powertool.api.android.CustomXmlAndroidAPI.SetXmlFileName ( String  filename) throws CustomXmlException
inline

Set the name of the xml project file
To be done as the first step, in order to load the project inside the library.
Notes:
This is the name of the project file created with CustomPowerTool (CPT) Editor (it has .xml extension)
In fact, you must initialize CPT library with the project file that you want to print.

In the same location it is necessary to find "images" and "fonts" directories, as created by CPT Editor.

Parameters
filenameAbsolute file path of the xml project file
Returns
0 in case of success, otherwise -1
Exceptions
CustomXmlExceptionif file doesn't exist

◆ SetXmlObjectFromParamFile()

int it.custom.powertool.api.android.CustomXmlAndroidAPI.SetXmlObjectFromParamFile ( String  xmlParameterFileName) throws CustomXmlException
inline

Create a list of tag/value using the supplied xml parameter file and apply it to the xml project file (see SetXmlObjectTag() for tag/value meaning).
The parameter file must be in the format produced by CPT Editor
Notes:
The xml parameter file is generated by CPT Editor, and has extension ".param.xml".
The xml parameter file contains the description of the "variable" part of the layout to print, in the form of xml nodes.
This file can be interpreted as a subset of the xml project file, containing only the "variable" properties.
Each node is identified by an Id and can have one or more properties.
It can be modifed manually by the user.

Example:
This is a part of a xml parameter file:
....
<CustomParam class="text" id="TextBox1">
<text>new string 1</text>
</CustomParam>

<CustomParam class="text" id="TextBox2">
<text>new string 2</text>
</CustomParam>
.....
A call to SetXmlObjectFromParamFile() produces the same result of multiple calls to SetXmlObjectTag()
In this example, it is equivalent to:
SetXmlObjectTag("TextBox1.text", "new string 1");
SetXmlObjectTag("TextBox2.text", "new string 2");

Parameters
xmlParameterFileNameAbsolute file path of xml parameter file
Returns
0 in case of success, otherwise -1
Exceptions
CustomXmlExceptionif parser is not created (project file not opened) or parameter file doesn't exist

◆ SetXmlObjectTag()

int it.custom.powertool.api.android.CustomXmlAndroidAPI.SetXmlObjectTag ( String  tag,
String  value 
) throws CustomXmlException
inline

Set the value of the element specified by tag (format Id.Property)
In the xml file identify an element with the specified tag and overwrite the value with the supplied one.
Notes:
The xml project file contains the description of the layout to print in the form of xml nodes.
Each node is identified by an Id, and has many properties.
You can change the value of a property, and the document will be printed with this new value.

Example:
This is a part of the xml project file describing a textbox field:
<CustomItem class="text" id="TextBox0">
....
<text>original string</text>
<fontname>Arial</fontname>
<fontsize>8</fontsize>
.....
</CustomItem>

Use: SetXmlObjectTag("TextBox0.text", "new string");
In the printed document, the TextBox0 field will be printed with "new string" instead of "original string".

Parameters
tagXml Tag (in the form Id.Property) to identify an element
valueValue assigned to the element identified by tag
Returns
0 in case of success, otherwise -1
Exceptions
CustomXmlExceptionif parser is not created (project file not opened)