コード例 #1
0
ファイル: PrintService.cs プロジェクト: MobileFit/CoachV2
		public override void OnWrite (PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, Android.Print.PrintDocumentAdapter.WriteResultCallback callback)
		{
			InputStream input = null;
			OutputStream output = null;

			try {


				input = new FileInputStream (PathToDoc);
				output = new FileOutputStream (destination.FileDescriptor);

				byte[] buf = new byte[1024];
				int bytesRead;

				while ((bytesRead = input.Read (buf)) > 0) {
					output.Write (buf, 0, bytesRead);
				}

				callback.OnWriteFinished (new PageRange[]{ PageRange.AllPages });

			} catch (System.IO.FileNotFoundException ee) {
				Insights.Report (ee);
			} catch (Exception e) {
				Insights.Report (e);
			} finally {
				try {
					input.Close ();
					output.Close ();
				} catch (Java.IO.IOException e) {
					e.PrintStackTrace ();
				}
			}
		}
コード例 #2
0
        public override void OnWrite(PageRange[] pages, ParcelFileDescriptor destination,
                                      CancellationSignal cancellationSignal, WriteResultCallback callback)
        {
            PrintedPdfDocument.Page page = document.StartPage(0);

            page.Canvas.Scale(scale, scale);

            page.Canvas.DrawText(text, page.Canvas.ClipBounds.Right / 2, page.Canvas.ClipBounds.Bottom / 2, new Android.Graphics.Paint());
            
            document.FinishPage(page);

            WritePrintedPdfDoc(destination);

            document.Close();

            document.Dispose();

            callback.OnWriteFinished(pages);
        }
コード例 #3
0
			public override void OnWrite (PageRange[] pages, ParcelFileDescriptor destination,
				CancellationSignal cancellationSignal, WriteResultCallback callback)
			{
				mWrappedInstance.OnWrite (pages, destination, cancellationSignal, callback);
			}