Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

printing receipt in java using graphic2d

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to experiment on codes I found online in printing a receipt using graphic2d, so far all I've been able to print are short prints of paper even though I've adjusted the dimensions, and this is confusing to me as this is my first time handling receipt printing. Also I don't quite know why the dimensions are not reflecting properly. Can anyone enlighten me regarding this matter, also I am using a SRP-325plus bixolon thermal printer.

Paper Print Dimension: 80x297mm

 
Rancher
Posts: 1050
27
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not had to print anything to a printer from Java for years, but in the early days I noticed I was getting a perfect print only it was tiny. I had to adjust the print image size to accommodate the dpi of the printer. 2D is approximately 72 dbi and our printers where printing at 600 dpi, so the image was very small.
 
rodolfo tuble
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Les Morgan wrote:I have not had to print anything to a printer from Java for years, but in the early days I noticed I was getting a perfect print only it was tiny. I had to adjust the print image size to accommodate the dpi of the printer. 2D is approximately 72 dbi and our printers where printing at 600 dpi, so the image was very small.



On which part do I adjust this? Also what does offset (100, 100) mean?

Thank you
 
Les Morgan
Rancher
Posts: 1050
27
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The (100, 100) refers to placement of the print object, in this case the string on the graphics context at x position 100 and y position 100.

What I eneded up doing is just making a BufferedImage and using drawImage in the Graphics API to render the image to the BufferedImage's graphics context at the appropriate size for my printer (600 dpi).

rodolfo tuble wrote:

Les Morgan wrote:I have not had to print anything to a printer from Java for years, but in the early days I noticed I was getting a perfect print only it was tiny. I had to adjust the print image size to accommodate the dpi of the printer. 2D is approximately 72 dbi and our printers where printing at 600 dpi, so the image was very small.



On which part do I adjust this? Also what does offset (100, 100) mean?

Thank you

 
rodolfo tuble
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Les Morgan wrote:

What I eneded up doing is just making a BufferedImage and using drawImage in the Graphics API to render the image to the BufferedImage's graphics context at the appropriate size for my printer (600 dpi).



Does this same principle apply to only printing text?
 
Saloon Keeper
Posts: 26047
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you're dealing with graphical media - whether it's on-screen or printed, the graphics functions do everything. Including text. Often the printer's actual text-printing capabilities aren't used at all because the fonts being used are bitmaps generated by the applications graphic services.
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic