I am trying to print a receipt from a Bluetooth thermal printer with a receipt size of
•Paper Width: 57 +/- 0.5mm •Print Width: 48 +/- 0.5mm
Bluetooth thermal printer model (might help for more specification)
PT-210 Portable Wireless Bluetooth Thermal Printer Handheld 58mm Receipt
Here is my current code, I am using iTextPDF package
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);
}
I had to try different approach so far :
// 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.
When the item size exceeds more than 10 items, all of my bottom text becomes very small. I'm trying to make a POS with receipt printing but it seems like do i need to buy a different printer? or is there any other way around to fix this?
Thank you