Printing with Mptprinter

Asked

Viewed 45 times

0

Good morning, I need to make an impression using Mptprinter. However this impression needs to have a certain alignment, for example the values need to be printed from right to left. However when I use the setHorizontalAlignment(Control.RIGHT) command it is fully aligned to the right of the paper, and I need to print 3 information aligned from right to left on the same line (Values information). I wonder how I do this kind of alignment, what commands I can use?

Follow the test code (just a test of printing the order items).

protected void imprimirItensNota(NotaFiscal nota){
    try {

        mPrinter.setFont(true, false, false, false);

        mPrinter.setXPos(1);
        mPrinter.print("Produto");

        mPrinter.setXPos(270);
        mPrinter.print("Qtde.");

        mPrinter.setXPos(360);
        mPrinter.print("Unit.");

        mPrinter.setXPos(440);
        mPrinter.print("Desc.");

        mPrinter.setXPos(510);
        mPrinter.print("Total");

        mPrinter.newLine();         

        for (int i = 1; i < 15; i++) {
            mPrinter.setXPos(1);
            mPrinter.print("Produto de teste");

            mPrinter.setXPos(255);
            mPrinter.print("250,00");

            mPrinter.setXPos(350);
            mPrinter.print("999,99");

            mPrinter.setXPos(430);
            mPrinter.print("999,99");

            mPrinter.setXPos(495);
            mPrinter.print("999,99");
            mPrinter.newLine(1);                
        }           


    } catch (Exception e) {
        MessageBox.showException(e, true);
    }       
}
  • It would be interesting to post the code you’re trying to help us too

  • An alternative to this would be doing space-padding. Have you tried to toggle the horizontal alignment? Type, alinhamento esquerda => texto informativo => alinhamento direita => texto valor?

  • Good morning Jefferson, you’d have some role model?

  • How do I treat words with accentuation? the words that contain "ç" or "ã", are going out with a very strange character.

  • Another alternative would be to create an image and print the image through Mptprinter... just use Monoimage, capture the graphcs of it (monoImage.getGraphics()) and "draw" your print in Graphics, with this I managed to use accentuation smoothly and for alignment you can do easily by calculation

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.