package com.simplypos.simply.util.printUtil; import static com.simplypos.simply.constant.AppConstants.SP_ESC_POS_PRINTER; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.Context; import android.text.TextUtils; import android.util.Log; import com.dantsu.escposprinter.connection.DeviceConnection; import com.dantsu.escposprinter.connection.bluetooth.BluetoothConnection; import com.dantsu.escposprinter.connection.bluetooth.BluetoothPrintersConnections; import com.dantsu.escposprinter.connection.tcp.TcpConnection; import com.simplypos.simply.R; import com.simplypos.simply.dao.model.printer.EscPosPrinter; import com.simplypos.simply.dao.storage.SharedPreference; import com.simplypos.simply.pojo.data.DepartmentReport; import com.simplypos.simply.pojo.data.InvoiceAddResponse; import com.simplypos.simply.pojo.data.InvoiceReport; import com.simplypos.simply.pojo.data.InvoiceTypesReport; import com.simplypos.simply.pojo.data.Payment; import com.simplypos.simply.pojo.data.PrintCompanyDetail; import com.simplypos.simply.pojo.data.PrintDetails; import com.simplypos.simply.pojo.data.PrintDetailsLineItem; import com.simplypos.simply.pojo.data.PrintDetailsTax; import com.simplypos.simply.pojo.data.VatRateInvoiceTypeReport; import com.simplypos.simply.pojo.data.VatRateReport; import com.simplypos.simply.util.NumberUtil; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; public class PrintUtil { private static final String TAG = PrintUtil.class.getSimpleName(); public static int charactersInLine = 32; public static Context mContext = null; public static void printData(Context context, InvoiceAddResponse invoiceAddResponse) { printData(context, invoiceAddResponse.getPrintDetails()); } public static void printData(Context context, PrintDetails printDetailObj) { mContext = context; EscPosPrinter printerSettingsObject = getPrinterSettings(); if (printerSettingsObject != null && printDetailObj != null) { DeviceConnection deviceConnection = getDeviceConnection(context, printerSettingsObject); if (deviceConnection != null) { AsyncEscPosPrinter data = getAsyncEscPosPrinter(deviceConnection, printDetailObj, printerSettingsObject.getSelectedPageSize()); if (printerSettingsObject.getSelectedInterfaceType().equals(context.getString(R.string.bluetooth))) { new AsyncBluetoothEscPosPrint( context, new AsyncEscPosPrint.OnPrintFinished() { @Override public void onError(AsyncEscPosPrinter asyncEscPosPrinter, int codeException) { Log.e("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : An error occurred !"); } @Override public void onSuccess(AsyncEscPosPrinter asyncEscPosPrinter) { Log.i("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : Print is finished !"); } } ).execute(data); } else { try { new AsyncTcpEscPosPrint( context, new AsyncEscPosPrint.OnPrintFinished() { @Override public void onError(AsyncEscPosPrinter asyncEscPosPrinter, int codeException) { Log.e("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : An error occurred !"); if (deviceConnection != null && deviceConnection.isConnected()) deviceConnection.disconnect(); } @Override public void onSuccess(AsyncEscPosPrinter asyncEscPosPrinter) { Log.i("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : Print is finished !"); if (deviceConnection != null && deviceConnection.isConnected()) deviceConnection.disconnect(); } } ).execute(data); } catch (Exception e) { new AlertDialog.Builder(context) .setTitle("Invalid TCP port address") .setMessage("Port field must be an integer.") .show(); e.printStackTrace(); } } } else { Log.w(TAG, "deviceConnection is null"); } } else { new AlertDialog.Builder(context) .setTitle("Printer") .setMessage("Printer Settings are not configured") .show(); } } public static EscPosPrinter getPrinterSettings() { return (EscPosPrinter) SharedPreference.getObjectPreferences(SP_ESC_POS_PRINTER, EscPosPrinter.class); } private static String getReportString(InvoiceReport invoiceReport) { String transactionsLabel = mContext.getString(R.string.str_transactions); String turnoverLabel = mContext.getString(R.string.str_turnover); String netSaleLabel = mContext.getString(R.string.str_net_sale); String salesVatLabel = mContext.getString(R.string.sales_vat); String returnsLabel = mContext.getString(R.string.str_returns); String returnsVatLabel = mContext.getString(R.string.str_returns_vat); String str_breakdown_by_payment_type = mContext.getString(R.string.str_breakdown_by_payment_type); String str_sales_totals_by_department = mContext.getString(R.string.str_sales_totals_by_department); String str_total_sales = mContext.getString(R.string.str_total_sales); String str_net_sales = mContext.getString(R.string.str_net_sales); String str_vat_ = mContext.getString(R.string.str_vat_); String str_breakdown_by_vat_rate = mContext.getString(R.string.str_breakdown_by_vat_rate); String str_breakdown_by_invoice_type = mContext.getString(R.string.str_breakdown_by_invoice_type); StringBuilder itemsString = new StringBuilder(); itemsString.append("[C]<font size='tall'>Report</font>").append("\n"); itemsString.append(getLineSeparator()).append("\n"); itemsString.append("[L]Date From").append("[R]" + invoiceReport.getDateFrom()).append("\n"); itemsString.append("[L]Date To").append("[R]" + invoiceReport.getDateTo()).append("\n"); itemsString.append(getLineSeparator()).append("\n"); itemsString.append("\n"); itemsString.append("[L]<b>" + "Total" + "</b>").append("\n"); itemsString.append("[L]" + transactionsLabel + "").append("[R]" + invoiceReport.getTransactions()).append("\n"); itemsString.append("[L]" + turnoverLabel + "").append("[R]" + invoiceReport.getTurnOver()).append("\n"); itemsString.append("[L]" + netSaleLabel + "").append("[R]" + invoiceReport.getNetSales()).append("\n"); itemsString.append("[L]" + salesVatLabel + "").append("[R]" + invoiceReport.getSalesVAT()).append("\n"); itemsString.append("[L]" + returnsLabel + "").append("[R]" + invoiceReport.getReturns()).append("\n"); itemsString.append("[L]" + returnsVatLabel + "").append("[R]" + invoiceReport.getReturnVAT()).append("\n"); itemsString.append("\n"); if (invoiceReport.getPayments() != null) { itemsString.append(getLineSeparator()).append("\n"); itemsString.append("\n"); itemsString.append("[L]<b>" + str_breakdown_by_payment_type + "</b>").append("\n"); for (Payment lineItem : invoiceReport.getPayments()) { itemsString.append("[L]" + lineItem.getName() + "").append("[R]" + lineItem.getValue()).append("\n"); } itemsString.append("\n"); } if (invoiceReport.getDepartmentsReport() != null) { itemsString.append(getLineSeparator()).append("\n"); itemsString.append("\n"); itemsString.append("[L]<b>" + str_sales_totals_by_department + "</b>").append("\n"); for (DepartmentReport lineItem : invoiceReport.getDepartmentsReport()) { itemsString.append("[L]<b>" + lineItem.getName() + "</b>").append("\n"); itemsString.append("[L]" + lineItem.getVatRate()).append("\n"); itemsString.append("[L]" + str_total_sales + "").append("[R]" + lineItem.getTotalSales()).append("\n"); itemsString.append("[L]" + str_net_sales + "").append("[R]" + lineItem.getNetSales()).append("\n"); itemsString.append("[L]" + str_vat_ + "").append("[R]" + lineItem.getVatAmount()).append("\n"); itemsString.append("\n"); } } if (invoiceReport.getVatRates() != null) { itemsString.append(getLineSeparator()).append("\n"); itemsString.append("\n"); itemsString.append("[L]<b>" + str_breakdown_by_vat_rate + "</b>").append("\n"); for (VatRateReport lineItem : invoiceReport.getVatRates()) { itemsString.append("[L]<b>" + lineItem.getName() + "</b>").append("\n"); itemsString.append("[L]" + "Total gross:" + "").append("[R]" + lineItem.getTotalSales()).append("\n"); itemsString.append("[L]" + "Net amount:" + "").append("[R]" + lineItem.getNetSales()).append("\n"); itemsString.append("[L]" + "VAT amount:" + "").append("[R]" + lineItem.getVatAmount()).append("\n"); itemsString.append("\n"); } } if (invoiceReport.getInvoiceTypes() != null) { itemsString.append(getLineSeparator()).append("\n"); itemsString.append("\n"); itemsString.append("[L]<b>" + str_breakdown_by_invoice_type + "</b>").append("\n"); for (InvoiceTypesReport lineItem : invoiceReport.getInvoiceTypes()) { itemsString.append("[L]<b>" + lineItem.getName() + "</b>").append("\n"); itemsString.append("[L]" + "Total gross sales:" + "").append("[R]" + lineItem.getTotalSales()).append("\n"); itemsString.append("[L]" + "Net sales:" + "").append("[R]" + lineItem.getNetSales()).append("\n"); if(lineItem.getVatRates() !=null) { for (VatRateInvoiceTypeReport lineItemVAT : lineItem.getVatRates()) { itemsString.append("[L]" +lineItemVAT.getName()) .append("[R]" + lineItemVAT.getValue()).append("\n"); } } itemsString.append("\n"); } } itemsString.append(getLineSeparator()).append("\n"); itemsString.append("[C]").append("End of Report").append("\n"); itemsString.append(getLineSeparator()).append("\n"); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy HH:mm"); String currentDateandTime = sdf.format(new Date()); itemsString.append("[L]" + "Printed on:" + "").append("[R]" + currentDateandTime).append("\n"); itemsString.append("\n"); itemsString.append("\n"); itemsString.append("\n"); return itemsString.toString(); } public static void printReport(Context context, InvoiceReport invoiceReport) { mContext = context; EscPosPrinter printerSettingsObject = getPrinterSettings(); if (printerSettingsObject != null && invoiceReport != null) { DeviceConnection deviceConnection = getDeviceConnection(context, printerSettingsObject); if (deviceConnection != null) { AsyncEscPosPrinter data = getReport_AsyncEscPosPrinter(deviceConnection, invoiceReport, printerSettingsObject.getSelectedPageSize()); if (printerSettingsObject.getSelectedInterfaceType().equals(context.getString(R.string.bluetooth))) { new AsyncBluetoothEscPosPrint( context, new AsyncEscPosPrint.OnPrintFinished() { @Override public void onError(AsyncEscPosPrinter asyncEscPosPrinter, int codeException) { Log.e("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : An error occurred !"); } @Override public void onSuccess(AsyncEscPosPrinter asyncEscPosPrinter) { Log.i("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : Print is finished !"); } } ).execute(data); } else { try { new AsyncTcpEscPosPrint( context, new AsyncEscPosPrint.OnPrintFinished() { @Override public void onError(AsyncEscPosPrinter asyncEscPosPrinter, int codeException) { Log.e("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : An error occurred !"); if (deviceConnection != null && deviceConnection.isConnected()) deviceConnection.disconnect(); } @Override public void onSuccess(AsyncEscPosPrinter asyncEscPosPrinter) { Log.i("Async.OnPrintFinished", "AsyncEscPosPrint.OnPrintFinished : Print is finished !"); if (deviceConnection != null && deviceConnection.isConnected()) deviceConnection.disconnect(); } } ).execute(data); } catch (Exception e) { new AlertDialog.Builder(context) .setTitle("Invalid TCP port address") .setMessage("Port field must be an integer.") .show(); e.printStackTrace(); } } } else { Log.w(TAG, "deviceConnection is null"); } } else { new AlertDialog.Builder(context) .setTitle("Printer") .setMessage("Printer Settings are not configured") .show(); } } @SuppressLint("MissingPermission") private static DeviceConnection getDeviceConnection(Context context, EscPosPrinter printer) { DeviceConnection connection = null; if (printer.getSelectedInterfaceType() != null) { if (printer.getSelectedInterfaceType().equals(context.getString(R.string.bluetooth))) { final BluetoothConnection[] bluetoothDevicesList = (new BluetoothPrintersConnections()).getList(); if (bluetoothDevicesList != null) { List<BluetoothConnection> printerList = Arrays.asList(bluetoothDevicesList); if (!printerList.isEmpty()) { for (BluetoothConnection btConnection : printerList) { if (btConnection.getDevice().getName().equals(printer.getName())) { connection = btConnection; } } if (connection == null) { connection = bluetoothDevicesList[0]; } } } } else { String I = printer.getAddress(); String I2 = printer.getPort(); connection = new TcpConnection(printer.getAddress(), Integer.parseInt(printer.getPort())); } } else { Log.w(TAG, "InterfaceType is null"); } return connection; } private static AsyncEscPosPrinter getReport_AsyncEscPosPrinter(DeviceConnection printerConnection, InvoiceReport printDetailObj, Float pageSize) { if (pageSize == 110) { charactersInLine = 68; } else if (pageSize == 80 || pageSize == 76) { pageSize = 76f; charactersInLine = 48; } else { charactersInLine = 32; } AsyncEscPosPrinter escPosPrinter = new AsyncEscPosPrinter(printerConnection, 203, pageSize, charactersInLine); return escPosPrinter.addTextToPrint( getHeaderDataStringReport(printDetailObj.getCompanyDetail(), pageSize) + getReportString(printDetailObj) ); } private static AsyncEscPosPrinter getAsyncEscPosPrinter(DeviceConnection printerConnection, PrintDetails printDetailObj, Float pageSize) { if (pageSize == 110) { charactersInLine = 68; } else if (pageSize == 80 || pageSize == 76) { pageSize = 76f; charactersInLine = 48; } else { charactersInLine = 32; } AsyncEscPosPrinter escPosPrinter = new AsyncEscPosPrinter(printerConnection, 203, pageSize, charactersInLine); return escPosPrinter.addTextToPrint( getHeaderDataString(printDetailObj, pageSize) + getItemsString(printDetailObj) + getPaymentDetails(printDetailObj) + getReceiptNotes(printDetailObj) + getBottomNotes(printDetailObj)); } private static String getHeaderDataString(PrintDetails printDetailObj, Float pageSize) { StringBuilder builder = new StringBuilder(); //builder.append("[C]DBA Name" + "\n"); builder.append("[C]<b>").append(printDetailObj.getCompanyName()).append("</b>\n"); builder.append("[C]").append(printDetailObj.getCompanyLegalName()).append("\n"); builder.append("[C]").append(printDetailObj.getCompanyActivity()).append("\n"); String branchAddressLabel = mContext.getString(R.string.str_branch_address); String mainAddressLabel = mContext.getString(R.string.str_main_address); String vatNrLabel = mContext.getString(R.string.str_vat_nr); String taxAuthLabel = mContext.getString(R.string.str_tax_auth); if (!TextUtils.isEmpty(printDetailObj.getBranchAddress())) { builder.append("[C]").append(branchAddressLabel).append("\n"); builder.append("[C]").append(printDetailObj.getBranchAddress()).append("\n"); } builder.append("[C]").append(mainAddressLabel).append("\n"); if (!TextUtils.isEmpty(printDetailObj.getCompanyAddress())) { builder.append("[C]").append(printDetailObj.getCompanyAddress()).append("\n"); } builder.append("[C]").append(vatNrLabel).append(" ").append(printDetailObj.getCompanyVatNumber()).append("\n"); builder.append("[C]").append(taxAuthLabel).append(" ").append(printDetailObj.getCompanyTaxAuthority()).append("\n"); if (!TextUtils.isEmpty(printDetailObj.getCompanyWebsite())) { builder.append("[C]").append(printDetailObj.getCompanyWebsite()).append("\n"); } if (!TextUtils.isEmpty(printDetailObj.getCompanyEmail())) { builder.append("[C]").append(printDetailObj.getCompanyEmail()).append("\n"); } builder.append("[C]<b>").append(printDetailObj.getInvoiceTypeTitle()).append("</b>\n"); builder.append("[C]").append(printDetailObj.getInvoiceNumber()).append("\n"); String customerDetailsLabel = mContext.getString(R.string.str_customer_detail); String legalNameLabel = mContext.getString(R.string.str_legal_name); String activityLabel = mContext.getString(R.string.str_activity); String billingAddressLabel = mContext.getString(R.string.str_billing_address); String shippingAddressLabel = mContext.getString(R.string.str_shipping_address); String telNumberLabel = mContext.getString(R.string.str_mobile_phone); String vatNumberLabel = mContext.getString(R.string.str_vat_number); String taxAuthorityLabel = mContext.getString(R.string.str_tax_authority); builder.append("[C]" + getLineSeparator() + "\n"); if (printDetailObj.getCustomerDetails() != null) { builder.append("[C]<b>" + customerDetailsLabel + "</b>\n"); builder.append("[C]" + getLineSeparator() + "\n"); builder.append("[L]<b>" + legalNameLabel + "</b>\n"); builder.append("[L]").append(printDetailObj.getCustomerDetails().getLegalName()).append("\n"); if (printDetailObj.getCustomerDetails().getActivity() != null && printDetailObj.getCustomerDetails().getActivity().length() > 0) { builder.append("[L]").append("<b>" + activityLabel + "</b>").append("\n"); builder.append("[L]").append(printDetailObj.getCustomerDetails().getActivity()).append("\n"); } if (printDetailObj.getCustomerDetails().getBillingAddress() != null && printDetailObj.getCustomerDetails().getBillingAddress().length() > 0) { builder.append("[L]").append("<b>" + billingAddressLabel + "</b>").append("\n"); builder.append("[L]").append(printDetailObj.getCustomerDetails().getBillingAddress()).append("\n"); } if (printDetailObj.getCustomerDetails().getShippingAddress() != null && printDetailObj.getCustomerDetails().getShippingAddress().length() > 0) { builder.append("[L]").append("<b>" + shippingAddressLabel + "</b>").append("\n"); builder.append("[L]").append(printDetailObj.getCustomerDetails().getShippingAddress()).append("\n"); } if (!TextUtils.isEmpty(printDetailObj.getCustomerDetails().getMobile())) { builder.append("[L]").append("<b>" + telNumberLabel + "</b>").append("\n"); builder.append("[L]").append(printDetailObj.getCustomerDetails().getMobile()).append("\n"); } if (!TextUtils.isEmpty(printDetailObj.getCustomerDetails().getVatNumber()) || !TextUtils.isEmpty(printDetailObj.getCustomerDetails().getTaxAuthority())) { builder.append("[L]").append("<b>" + vatNumberLabel + " - " + taxAuthorityLabel + " </b>").append("\n"); builder.append("[L]") .append(printDetailObj.getCustomerDetails().getVatNumber()) .append(" - ") .append(printDetailObj.getCustomerDetails().getTaxAuthority()) .append("\n"); } builder.append("[C]" + getLineSeparator() + "\n"); } builder.append("[C]<b>").append(printDetailObj.getInvoiceDate()).append("</b>\n"); builder.append("[C]" + getLineSeparator() + "\n\n"); return builder.toString(); } private static String getHeaderDataStringReport(PrintCompanyDetail printDetailObj, Float pageSize) { StringBuilder builder = new StringBuilder(); //builder.append("[C]DBA Name" + "\n"); builder.append("\n"); builder.append("[C]<b>").append(printDetailObj.getName()).append("</b>\n"); builder.append("[C]").append(printDetailObj.getLegalName()).append("\n"); builder.append("[C]").append(printDetailObj.getActivity()).append("\n"); String branchAddressLabel = mContext.getString(R.string.str_branch_address); String mainAddressLabel = mContext.getString(R.string.str_main_address); String vatNrLabel = mContext.getString(R.string.str_vat_nr); String taxAuthLabel = mContext.getString(R.string.str_tax_auth); if (!TextUtils.isEmpty(printDetailObj.getBranchAddress())) { builder.append("[C]").append(branchAddressLabel).append("\n"); builder.append("[C]").append(printDetailObj.getBranchAddress()).append("\n"); } builder.append("[C]").append(mainAddressLabel).append("\n"); if (!TextUtils.isEmpty(printDetailObj.getAddress())) { builder.append("[C]").append(printDetailObj.getAddress()).append("\n"); } builder.append("[C]").append(vatNrLabel).append(" ").append(printDetailObj.getVatNumber()).append("\n"); builder.append("[C]").append(taxAuthLabel).append(" ").append(printDetailObj.getTaxAuthority()).append("\n"); if (!TextUtils.isEmpty(printDetailObj.getWebsite())) { builder.append("[C]").append(printDetailObj.getWebsite()).append("\n"); } if (!TextUtils.isEmpty(printDetailObj.getEmail())) { builder.append("[C]").append(printDetailObj.getEmail()).append("\n"); } builder.append("[C]" + getLineSeparator() + "\n"); builder.append("[C]<b>").append(printDetailObj.getRegisterName()).append("</b>\n"); builder.append("[C]" + getLineSeparator() + "\n"); return builder.toString(); } public static String getLineSeparator() { StringBuilder str = new StringBuilder(); for (int i = 0; i < charactersInLine; i++) { str.append("-"); } return str.toString(); } private static String getItemsString(PrintDetails printDetailObj) { StringBuilder itemsString = new StringBuilder(); for (PrintDetailsLineItem lineItem : printDetailObj.getLineItem()) { String vatStr = lineItem.getVat(); itemsString.append("[L]").append("* ") .append(lineItem.getQuantity()) .append(" X ") .append(lineItem.getPrice()) //VAT 24 .append("[R]").append(lineItem.getVat()).append("%\n"); itemsString.append("[L]<b>").append(lineItem.getTitle()).append("</b>") .append("[R]<b>").append(lineItem.getTotalWithVAT()).append("</b>\n"); if (lineItem.isDiscount()) { itemsString.append("[L]") .append("-" + lineItem.getDisc() + "% ") .append(lineItem.getDiscAmount()).append("\n"); } if (!TextUtils.isEmpty(lineItem.getNote())) { itemsString.append("[L]").append(lineItem.getNote()).append("\n"); } itemsString.append("\n"); } return itemsString.toString(); } private static String getPaymentDetails(PrintDetails printDetailObj) { String netAmountLabel = mContext.getString(R.string.net_amount_str); String totalLabel = mContext.getString(R.string.str_total); String changeLabel = mContext.getString(R.string.str_change); StringBuilder builder = new StringBuilder(); // builder.append("[C]" + getLineSeparator() + "\n"); builder.append("[L]" + netAmountLabel + "[R]€") .append(NumberUtil.FormatNumberTwoDecimal(printDetailObj.getNetAmount())) .append("\n"); // if (printDetailObj.getTaxes() != null) { for (PrintDetailsTax lineItem : printDetailObj.getTaxes()) { //[L]VAT 24.00%:[R]€ builder.append("[L]").append(lineItem.getTitle()) .append(":[R]€") .append(lineItem.getAmount()) .append("\n"); } } // <font size='tall'>Report</font> builder.append("[L]<font size='tall'>" + totalLabel + "</font>[R]<font size='tall'>€") .append(NumberUtil.FormatNumberTwoDecimal(printDetailObj.getGrandTotal())).append("</font>\n") .append("[C]" + getLineSeparator() + "\n") .append("[L]<b>") .append(printDetailObj.getPaymentTitle()) .append(":</b>[R]<b>") .append(NumberUtil.FormatNumberTwoDecimal(printDetailObj.getPaymentTotal())) .append("</b>\n"); if (printDetailObj.isShowChange()) { builder.append("[L]" + changeLabel + "[R]") .append(printDetailObj.getChangeAmount()) .append("\n"); } builder.append("[C]" + getLineSeparator() + "\n"); return builder.toString(); } private static String getReceiptNotes(PrintDetails printDetailObj) { StringBuilder builder = new StringBuilder(); if (printDetailObj.getReceiptNotes() != null) { builder.append("[C]" + getLineSeparator() + "\n") .append("[L]<b>").append(printDetailObj.getReceiptNotes().getNotesLine1()).append("</b>\n"); if (printDetailObj.getReceiptNotes().getNotesLine2() != null && printDetailObj.getReceiptNotes().getNotesLine2().length() > 0) { builder.append("[L]<b>").append(printDetailObj.getReceiptNotes().getNotesLine2()).append("</b>\n"); } if (printDetailObj.getReceiptNotes().getNotesLine3() != null && printDetailObj.getReceiptNotes().getNotesLine3().length() > 0) { builder.append("[L]<b>").append(printDetailObj.getReceiptNotes().getNotesLine3()).append("</b>\n"); } } return builder.toString(); } private static String getBottomNotes(PrintDetails printDetailObj) { StringBuilder builder = new StringBuilder(); builder.append("[C]\n"); builder.append("[C]<qrcode size='16'>").append(printDetailObj.getQrCodeURL()).append("</qrcode>\n\n"); builder.append("[L]<b>Mark:</b>").append(" ").append(printDetailObj.getMark()).append("\n") .append("[L]<b>UID:</b>").append(" ").append(printDetailObj.getUid()).append("\n") .append("[L]<b>Auth:</b>").append(" ").append(printDetailObj.getAuthCode()).append("\n\n") .append("[C]Service Provider: SIMPLY CLOUD\n") .append("[C]www.simplycloud.gr\n\n"); if (printDetailObj.getPrintThankMsg() != null && printDetailObj.getPrintThankMsg().length() > 0) { builder.append("[L]<b>" + printDetailObj.getPrintThankMsg() + "</b>\n\n"); } builder.append("\n\n\n"); return builder.toString(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter