KimHJ 4 Posted November 14 (edited) I have added jar for Android and the pas files made with Java2Op, but I can't find out how to implement diffrent classes. Here is the Android code: DriverManager mDriverManager = DriverManager.getInstance(); Printer mPrinter = mDriverManager.getPrinter(); private void printText() { int printStatus = mPrinter.getPrinterStatus(); if (printStatus == SdkResult.SDK_PRN_STATUS_PAPEROUT) { //out of paper } else { PrnStrFormat format = new PrnStrFormat(); format.setTextSize(30); format.setAli(Layout.Alignment.ALIGN_CENTER); format.setStyle(PrnTextStyle.BOLD); format.setFont(PrnTextFont.CUSTOM); format.setPath(Environment.getExternalStorageDirectory() + "/fonts/simsun.ttf"); mPrinter.setPrintAppendString("POS SALES SLIP", format); format.setTextSize(25); format.setStyle(PrnTextStyle.NORMAL); format.setAli(Layout.Alignment.ALIGN_NORMAL); mPrinter.setPrintAppendString(" ", format); mPrinter.setPrintAppendString("MERCHANGT NAME:" + " Test ", format); mPrinter.setPrintAppendString("MERCHANT NO:" + " 123456789012345 ", format); mPrinter.setPrintAppendString("TERMINAL NAME:" + " 12345678 ", format); mPrinter.setPrintAppendString("OPERATOR NO:" + " 01 ", format); mPrinter.setPrintAppendString("CARD NO: ", format); format.setAli(Layout.Alignment.ALIGN_CENTER); format.setTextSize(30); format.setStyle(PrnTextStyle.BOLD); mPrinter.setPrintAppendString("6214 44** **** **** 7816", format); format.setAli(Layout.Alignment.ALIGN_NORMAL); format.setStyle(PrnTextStyle.NORMAL); format.setTextSize(25);mPrinter.setPrintAppendString(" ----------------------------- ", format); mPrinter.setPrintAppendString(" ", format); mPrinter.setPrintAppendString(" ", format); mPrinter.setPrintAppendString(" ", format); mPrinter.setPrintAppendString(" ", format); printStatus = mPrinter.setPrintStart(); } } Here is my code and the problem I have is how to get the Align_Center, PrnTextFont and PrnTextStyle? function TRegisterForm.SrDM: Jsdk_DriverManager; begin result := TJsdk_DriverManager.JavaClass.getInstance(); end; function TRegisterForm.SrPrinter:Boolean; var Printer: Jsdk_Printer; PrinterStatus: Integer; Format: JPrnStrFormat; begin Printer := SrDM.getPrinter; PrinterStatus := Printer.getPrinterStatus; if PrinterStatus = TJSdkResult.JavaClass.SDK_PRN_STATUS_PAPEROUT then ShowMessage('Out of Paper!') else begin Format.setTextSize(30); Format.setAli(Layout.Alignment.ALIGN_CENTER); // Don't work Format.setStyle(PrnTextStyle.BOLD); // Don't work Format.setFont(PrnTextFont.SANS_SERIF); // Don't work Printer.setPrintAppendString(StringToJString('This Is A Test'),Format); end; end; Here are the declaration in the pas file. JPrnStrFormatClass = interface(JObjectClass) ['{30EACE86-7064-41AA-A8B4-7C40BB72CC98}'] {class} function init: JPrnStrFormat; cdecl; end; [JavaSignature('com/zcs/sdk/print/PrnStrFormat')] JPrnStrFormat = interface(JObject) ['{1D59686F-788D-462F-AEE0-B237EFB771A2}'] function getAli: JLayout_Alignment; cdecl; function getAm: JAssetManager; cdecl; function getFont: JPrnTextFont; cdecl; function getLetterSpacing: Single; cdecl; function getLineSpacing: Single; cdecl; function getPath: JString; cdecl; function getStyle: JPrnTextStyle; cdecl; function getTextScaleX: Single; cdecl; function getTextSize: Integer; cdecl; function isUnderline: Boolean; cdecl; procedure setAli(alignment: JLayout_Alignment); cdecl; procedure setAm(assetManager: JAssetManager); cdecl; procedure setFont(prnTextFont: JPrnTextFont); cdecl; procedure setLetterSpacing(f: Single); cdecl; procedure setLineSpacing(f: Single); cdecl; procedure setPath(string_: JString); cdecl; procedure setStyle(prnTextStyle: JPrnTextStyle); cdecl; procedure setTextScaleX(f: Single); cdecl; procedure setTextSize(i: Integer); cdecl; procedure setUnderline(b: Boolean); cdecl; end; TJPrnStrFormat = class(TJavaGenericImport<JPrnStrFormatClass, JPrnStrFormat>) end; JPrnTextFontClass = interface(JEnumClass) ['{D6E7ECA2-0F36-40D7-9B31-DA57D2163DF7}'] {class} function _GetCUSTOM: JPrnTextFont; cdecl; {class} function _GetDEFAULT: JPrnTextFont; cdecl; {class} function _GetDEFAULT_BOLD: JPrnTextFont; cdecl; {class} function _GetMONOSPACE: JPrnTextFont; cdecl; {class} function _GetSANS_SERIF: JPrnTextFont; cdecl; {class} function _GetSERIF: JPrnTextFont; cdecl; {class} function valueOf(string_: JString): JPrnTextFont; cdecl; {class} function values: TJavaObjectArray<JPrnTextFont>; cdecl; {class} property CUSTOM: JPrnTextFont read _GetCUSTOM; {class} property DEFAULT: JPrnTextFont read _GetDEFAULT; {class} property DEFAULT_BOLD: JPrnTextFont read _GetDEFAULT_BOLD; {class} property MONOSPACE: JPrnTextFont read _GetMONOSPACE; {class} property SANS_SERIF: JPrnTextFont read _GetSANS_SERIF; {class} property SERIF: JPrnTextFont read _GetSERIF; end; [JavaSignature('com/zcs/sdk/print/PrnTextFont')] JPrnTextFont = interface(JEnum) ['{14867A07-0702-4815-9ED1-0D6A600CFD36}'] function toString: JString; cdecl; end; TJPrnTextFont = class(TJavaGenericImport<JPrnTextFontClass, JPrnTextFont>) end; JPrnTextStyleClass = interface(JEnumClass) ['{BE1B7FE3-C000-47A4-9083-EBAB4C8B91C5}'] {class} function _GetBOLD: JPrnTextStyle; cdecl; {class} function _GetBOLD_ITALIC: JPrnTextStyle; cdecl; {class} function _GetITALIC: JPrnTextStyle; cdecl; {class} function _GetNORMAL: JPrnTextStyle; cdecl; {class} function valueOf(string_: JString): JPrnTextStyle; cdecl; {class} function values: TJavaObjectArray<JPrnTextStyle>; cdecl; {class} property BOLD: JPrnTextStyle read _GetBOLD; {class} property BOLD_ITALIC: JPrnTextStyle read _GetBOLD_ITALIC; {class} property ITALIC: JPrnTextStyle read _GetITALIC; {class} property NORMAL: JPrnTextStyle read _GetNORMAL; end; [JavaSignature('com/zcs/sdk/print/PrnTextStyle')] JPrnTextStyle = interface(JEnum) ['{C44C79F4-E2E5-44E8-B1BE-C7F088C1DAFC}'] end; TJPrnTextStyle = class(TJavaGenericImport<JPrnTextStyleClass, JPrnTextStyle>) end; Thanks for any help. Edited November 14 by KimHJ Share this post Link to post
Dave Nottage 662 Posted November 14 2 minutes ago, KimHJ said: Here is my code and the problem I have is how to get the Align_Center, PrnTextFont and PrnTextStyle? Since they're class properties, obtain them via the imported type, and JavaClass. i.e. TJLayout_Alignment.JavaClass.ALIGN_CENTER TJPrnTextFont.JavaClass.SANS_SERIF TJPrnTextStyle.JavaClass.BOLD Also in your code you are not initializing Format, which would be like this: Format := TJPrnStrFormat.JavaClass.Init; Share this post Link to post
KimHJ 4 Posted November 14 (edited) Thanks Dave, I was trying to declare all the classes like I did with format, but I could not figur out the Alignment. PrnStyle: JPrnTextStyleClass; TextFont: JPrnTextFontClass; begin PrnStyle:= ? TextFont:= ? Format.setStyle(PrnStyle.BOLD); Format.setFont(TextFont.DEFAULT); That should work? Thanks again. Edited November 14 by KimHJ Share this post Link to post