Android Programming Press on the image to return to the main documentation page.

Printing

List of types:

PdfDocument
Printer

PdfDocument

PdfDocument can be used to create Pdf files with one or more pages.
Example:
pdf.Initialize
pdf.StartPage(595, 842) 'A4 size
pdf.Canvas.DrawLine(2, 2, 593 , 840, Colors.Blue, 4)
pdf.Canvas.DrawText("Hello", 100, 100, Typeface.DEFAULT_BOLD, 30, Colors.Yellow, "CENTER")
pdf.FinishPage
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "1.pdf", False)
pdf.WriteToStream(out)
out.Close
pdf.Close

Events:

None

Members:


  Canvas As CanvasWrapper [read only]

  Close

  FinishPage

  Initialize

  StartPage (Width As Int, Height As Int)

  WriteToStream (out As java.io.OutputStream)

Members description:

Canvas As CanvasWrapper [read only]
Returns the canvas that is used to draw on the current page.
Note that you should not use DIP units with this canvas.
Canvas.Bitmap will return a stub bitmap.
Close
Closes the document.
FinishPage
Finalizes the page drawings.
Initialize
StartPage (Width As Int, Height As Int)
Starts a new page. Make sure to call FinishPage when you are done drawing.
Width / Height - Page dimension measured in Postscript (1/72th of an inch).
WriteToStream (out As java.io.OutputStream)
Writes the document to the output stream.

Printer

The printer object allows printing bitmaps, html strings and WebView content using the system printing feature.
This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

None

Members:


  Initialize (EventName As String)

  PrintBitmap (JobName As String, Bitmap As android.graphics.Bitmap, Fit As Boolean)

  PrintHtml (JobName As String, Html As String)

  PrintPdf (JobName As String, Dir As String, FileName As String)

  PrintSupported As Boolean [read only]

  PrintWebView (JobName As String, WebView As android.webkit.WebView)

Members description:

Initialize (EventName As String)
Initializes the printer object. Currently there are no events.
PrintBitmap (JobName As String, Bitmap As android.graphics.Bitmap, Fit As Boolean)
Prints a bitmap. The system printing dialog will appear.
JobName - The print job name.
Bitmap - Bitmap to print.
Fit - If true then the bitmap will be scaled to fit, otherwise it will be scaled to fill and will be cropped.
PrintHtml (JobName As String, Html As String)
Prints the provided html string.
PrintPdf (JobName As String, Dir As String, FileName As String)
Prints a pdf document.
JobName - The print job name.
Dir / FileName - PDF file.
PrintSupported As Boolean [read only]
PrintWebView (JobName As String, WebView As android.webkit.WebView)
Prints the WebView content. Make sure to wait for the PageFinished event.
Top