![]() |
CPTAndroidAPI (CustomPowerTool Android Api)
1.26
|
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< CustomXmlDictionaryItem > | GetXmlTagValListFromParamFile (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... | |
|
inline |
Initialize class
appContext | Android context of the calling application |
|
inline |
Close and release all resources used by an instance of the class.
|
inline |
Get current API version
|
inline |
Get bold property for the font identified by fontname.
Prerequiste is loding the project (using SetXmlFileName())
fontname | Font family name |
CustomXmlException | if parser is not created (project file not opened) or in case of missing font |
|
inline |
Get italic property for the font identified by fontname.
Prerequiste is loding the project (using SetXmlFileName())
fontname | Font family name |
CustomXmlException | if parser is not created (project file not opened) or in case of missing font |
|
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".
tag | Xml Tag (in the form Id.Property) to identify an element |
CustomXmlException | if parser is not created (project file not opened) |
|
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.
CustomXmlException | if parser is not created (project file not opened) or in case of parsing problems |
|
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" }
xmlParameterFileName | Absolute file path of xml parameter file |
CustomXmlException | if parser is not created (project file not opened) or parameter file doesn't exist |
|
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())
filename | Absolute file path used to store the preview image. File path should have extension ".png" in order to get a png format image file |
CustomXmlException | if parser is not created (project file not opened) |
|
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)
prnDevice | Printing device, as returned by CustomAndroidAPI library |
CustomXmlException | if parser is not created (project file not opened) or printing device is invalid |
|
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)
prnDevice | Printing device, as returned by CustomAndroidAPI library |
left_align | Left alignment behavior, see PrintImage in CustomAndroidAPI library documentation |
widthOption | Scaling options, see PrintImage in CustomAndroidAPI library documentation |
width | Printed image width in pixel/dots in case of "Scale to Width" option selected, see PrintImage in CustomAndroidAPI library documentation |
CustomXmlException | if parser is not created (project file not opened) or printing device is invalid |
|
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.
filename | Absolute file path of the xml project file |
CustomXmlException | if file doesn't exist |
|
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");
xmlParameterFileName | Absolute file path of xml parameter file |
CustomXmlException | if parser is not created (project file not opened) or parameter file doesn't exist |
|
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".
tag | Xml Tag (in the form Id.Property) to identify an element |
value | Value assigned to the element identified by tag |
CustomXmlException | if parser is not created (project file not opened) |