enable printing but you can also send the following data formats to
Send 2 Printer for printing from your own applications:
- HTML content
- Text
- Image
- Canvas draw commands (via serialized Picture)
- Canvas draw commands rendered to a Bitmap
For example:
Using java Syntax Highlighting
- void printCanvasExample()
- {
- // create canvas to render on
- Picture picture = new Picture();
- Canvas c = picture.beginRecording( 240, 240 );
- // fill background with WHITE
- c.drawRGB( 0xFF, 0xFF, 0xFF );
- // draw text
- Paint p = new Paint();
- Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
- p.setTextSize( 18 );
- p.setTypeface( font );
- p.setAntiAlias(true);
- Rect textBounds = new Rect();
- p.getTextBounds( HELLO_WORLD, 0, HELLO_WORLD.length(), textBounds );
- int x = (c.getWidth() - (textBounds.right-textBounds.left)) / 2;
- int y = (c.getHeight() - (textBounds.bottom-textBounds.top)) / 2;
- c.drawText( HELLO_WORLD, x, y, p );
- // draw icon
- Bitmap icon = BitmapFactory.decodeResource( getResources(), R.drawable.icon );
- c.drawBitmap( icon, 0, 0, null );
- // stop drawing
- picture.endRecording();
- // queue canvas for printing
- File f = PrintUtils.saveCanvasPictureToTempFile( picture );
- if( f != null )
- {
- PrintUtils.queuePictureStreamForPrinting( this, f );
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
The following post contains sample code to print the above formats and
include a sample "Test Print" eclipse project:
http://hit-mob.com/forums/viewtopic.php?f=13&t=66
More information about the "Send 2 Printer" application:
http://hit-mob.com/forums/viewtopic.php?f=13&t=58


