1

我正在尝试从收据大小为的蓝牙热敏打印机打印收据

•纸张宽度:57 +/- 0.5mm •打印宽度:48 +/- 0.5mm

蓝牙热敏打印机型号(可能有助于更多规格)

PT-210 便携式无线蓝牙热敏打印机手持式 58 毫米收据

这是我当前的代码,我正在使用iTextPDF 包

 public void ForInventoryPDF() {
     //   Rectangle pagesize = new Rectangle(288, 700);
   
        Document document = new Document();
     //  Document document = new Document(pagesize);
     //** ^^ I tried to do this, but when i did. i can only show atleast 10 items in a right font size while the other 10 item shows in a very small font size.


        try {
            PdfWriter.getInstance(document, new FileOutputStream(SALESFILE));
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

// Open to write
        document.open();
       // document.setPageSize(PageSize.A8);

        document.addCreationDate();
        document.addAuthor("lafayet order");
        document.addCreator("Kiko lawrence");


        LineSeparator lineSeparator = new LineSeparator();
        lineSeparator.setLineColor(new BaseColor(0, 0, 0, 68));

        BaseFont urName = null;
        try {
            urName = BaseFont.createFont("/res/font/brandon_medium.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Font mOrderDetailsTitleFont = new Font(urName, 30.0f, Font.NORMAL, BaseColor.BLACK);
        Font dateFont = new Font(urName, 14.0f, Font.NORMAL, BaseColor.BLACK);

        // Creating Chunk
        Chunk mOrderDetailsTitleChunk = new Chunk("SALE SUMMARY - ANTIPOLO  ", mOrderDetailsTitleFont);
        Chunk dateChunk = new Chunk("Date : " + getDateTime() + "\n\n", dateFont);


        Paragraph mOrderDetailsTitleParagraph = new Paragraph(mOrderDetailsTitleChunk);
        mOrderDetailsTitleParagraph.setAlignment(Element.ALIGN_CENTER);

        Paragraph date = new Paragraph(dateChunk);
        date.setAlignment(Element.ALIGN_CENTER);
        date.setSpacingBefore(5);

        Paragraph address = new Paragraph("Version 1.2");
        address.setAlignment(Element.ALIGN_CENTER);

        try {
            document.add(mOrderDetailsTitleParagraph);
            document.add(address);
            document.add(date);
            document.add(lineSeparator);
            PdfPTable table = new PdfPTable(3);
            table.setWidthPercentage(100);
            table.addCell(getCell("Item Name", PdfPCell.ALIGN_CENTER));
            table.addCell(getCell("Quantity", PdfPCell.ALIGN_LEFT));
            table.addCell(getCell("Price", PdfPCell.ALIGN_RIGHT));
            document.add(table);
            document.add(new Paragraph("\n"));
        } catch (DocumentException e) {
            e.printStackTrace();
        }

        //START OF ORDER DETAILS
        if (inventoryModels != null && !inventoryModels.isEmpty()) {
            //**deleted unnecessary codes,
            //codes here are just for my items that i'm showing in the receipt.
        }

  
        document.close();
        openPdf(SALESFILE);

    }

到目前为止,我不得不尝试不同的方法:

   //   Rectangle pagesize = new Rectangle(288, 700);
      //  Document document = new Document(pagesize);
        //** ^^ I tried to do this, but when i did. i can only show atleast 10 items in a right font size while the other 10 item shows in a very small font size.

当项目大小超过 10 个项目时,我所有的底部文本都变得非常小。我正在尝试制作带有收据打印的 POS,但似乎我需要购买其他打印机?或者有没有其他方法可以解决这个问题?

谢谢

4

0 回答 0