public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { if (cancellationSignal.IsCanceled) { callback.OnLayoutCancelled(); } else { PrintDocumentInfo.Builder builder = new PrintDocumentInfo.Builder(StatsActivity.filename); builder.SetContentType(PrintContentType.Document).SetPageCount(PrintDocumentInfo.PageCountUnknown).Build(); callback.OnLayoutFinished(builder.Build(), !newAttributes.Equals(oldAttributes)); } }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { if (cancellationSignal.IsCanceled) { callback.OnLayoutCancelled(); return; } PrintDocumentInfo pdi = new PrintDocumentInfo.Builder(FileToPrint).SetContentType(PrintContentType.Document).Build(); callback.OnLayoutFinished(pdi, true); }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, Android.OS.CancellationSignal cancellationSignal, LayoutResultCallback callback, Android.OS.Bundle extras) { if (cancellationSignal.IsCanceled) { callback.OnLayoutCancelled(); return; } using var builder = new PrintDocumentInfo.Builder(_fileName); callback.OnLayoutFinished(builder .SetContentType(PrintContentType.Document) .Build(), true); }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { if (cancellationSignal.IsCanceled) { callback?.OnLayoutCancelled(); } else { var builder = new PrintDocumentInfo.Builder("filename.pdf"); builder.SetContentType(PrintContentType.Document) .SetPageCount(PrintDocumentInfo.PageCountUnknown); callback.OnLayoutFinished(builder.Build(), !(newAttributes == oldAttributes)); } }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { document = new PrintedPdfDocument(context, newAttributes); CalculateScale(newAttributes); var printInfo = new PrintDocumentInfo .Builder("pdf-test.pdf") .SetContentType(PrintContentType.Document) .SetPageCount(1) .Build(); callback.OnLayoutFinished(printInfo, true); }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { mPdfDocument = new PrintedPdfDocument(CrossPrint.appcontext, newAttributes); if (cancellationSignal.IsCanceled) { callback.OnLayoutCancelled(); return; } int pages = computePageCount(newAttributes); if (pages > 0) { PrintDocumentInfo info = new PrintDocumentInfo .Builder("pdf.pdf") .SetContentType(PrintContentType.Document) .SetPageCount(pages).Build(); callback.OnLayoutFinished(info, true); } else { callback.OnLayoutFailed("Page count calculation failed."); } }
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] native_parms) { try { // Create an adapter with the stats and an inflater // to load resources for the printer density. var adapter = new MotoGpStatAdapter(items, (LayoutInflater)self.mPrintContext.GetSystemService( Context.LayoutInflaterService)); int currentPage = 0; int pageContentHeight = 0; int viewType = -1; View view = null; var dummyParent = new LinearLayout(self.mPrintContext); dummyParent.Orientation = Android.Widget.Orientation.Vertical; int itemCount = adapter.Count; for (int i = 0; i < itemCount; i++) { // Be nice and respond to cancellation. if (IsCancelled) { return(null); } // Get the next view. int nextViewType = adapter.GetItemViewType(i); if (viewType == nextViewType) { view = adapter.GetView(i, view, dummyParent); } else { view = adapter.GetView(i, null, dummyParent); } viewType = nextViewType; // Measure the next view self.MeasureView(view); // Add the height but if the view crosses the page // boundary we will put it to the next page. pageContentHeight += view.MeasuredHeight; if (pageContentHeight > self.mRenderPageHeight) { pageContentHeight = view.MeasuredHeight; currentPage++; } } // Create a document info describing the result. PrintDocumentInfo info = new PrintDocumentInfo .Builder("MotoGP_stats.pdf") .SetContentType(PrintContentType.Document) .SetPageCount(currentPage + 1) .Build(); // We completed the layout as a result of print attributes // change. Hence, if we are here the content changed for // sure which is why we pass true as the second argument. callback.OnLayoutFinished(info, true); return(info); } catch (Java.Lang.Exception e) { // An unexpected error, report that we failed and // one may pass in a human readable localized text // for what the error is if known. callback.OnLayoutFailed((string)null); throw new RuntimeException(e); } }