Lines Matching refs:print
16 <li><a href="#print-manager">Connect to the Print Manager</a></li>
17 <li><a href="#print-adapter">Create a Print Adapter</a>
19 <li><a href="#doc-info">Compute print document info</a></li>
20 <li><a href="#write-file">Write a print document file</a></li>
31 to print an image or an HTML document. The print output for these types of applications requires
35 <p>Creating print output that is completely customized for your application requires more
37 communicate with the print framework, adjust to printer settings, draw page elements and
40 <p>This lesson shows you how you connect with the print manager, create a print adapter and
44 <h2 id="print-manager">Connect to the Print Manager</h2>
47 print request from your user is to connect to the Android print framework and obtain an instance
48 of the {@link android.print.PrintManager} class. This class allows you to initialize a print job
49 and begin the printing lifecycle. The following code example shows how to get the print manager
58 // Set job name, which will be displayed in the print queue
61 // Start a print job, passing in a PrintDocumentAdapter implementation
62 // to handle the generation of a print document
63 printManager.print(jobName, new MyPrintDocumentAdapter(getActivity()),
68 <p>The example code above demonstrates how to name a print job and set an instance of the {@link
69 android.print.PrintDocumentAdapter} class which handles the steps of the printing lifecycle. The
70 implementation of the print adapter class is discussed in the next section.</p>
73 <strong>Note:</strong> The last parameter in the {@link android.print.PrintManager#print print()}
74 method takes a {@link android.print.PrintAttributes} object. You can use this parameter to
82 <h2 id="print-adapter">Create a Print Adapter</h2>
84 <p>A print adapter interacts with the Android print framework and handles the steps of the
85 printing process. This process requires users to select printers and print options before creating
88 As these selections are made, the print framework asks your adapter to lay out and generate a
89 print document, in preparation for final output. Once a user taps the print button, the framework
90 takes the final print document and passes it to a print provider for output. During the printing
91 process, users can choose to cancel the print action, so your print adapter must also listen for
94 <p>The {@link android.print.PrintDocumentAdapter} abstract class is designed to handle the
96 in your print adapter in order to interact properly with the print framework:</p>
99 <li>{@link android.print.PrintDocumentAdapter#onStart onStart()} - Called once at the
100 beginning of the print process. If your application has any one-time preparation tasks to
103 <li>{@link android.print.PrintDocumentAdapter#onLayout onLayout()} - Called each time a
104 user changes a print setting which impacts the output, such as a different page size,
108 <li>{@link android.print.PrintDocumentAdapter#onWrite onWrite()} - Called to render printed
110 {@link android.print.PrintDocumentAdapter#onLayout onLayout()} call.</li>
111 <li>{@link android.print.PrintDocumentAdapter#onFinish onFinish()} - Called once at the end
112 of the print process. If your application has any one-time tear-down tasks to perform,
117 critical to the functioning of a print adapter.</p>
123 layout or print document writing work in separate {@link android.os.AsyncTask} objects.
127 <h3 id="doc-info">Compute print document info</h3>
129 <p>Within an implementation of the {@link android.print.PrintDocumentAdapter} class, your
131 number of pages for print job, given information about the printed page size.
132 The implementation of the {@link android.print.PrintDocumentAdapter#onLayout onLayout()} method in
134 print job in a {@link android.print.PrintDocumentInfo} class, including the number of pages and
136 android.print.PrintDocumentAdapter#onLayout onLayout()} method for a {@link
137 android.print.PrintDocumentAdapter}:
159 // Return print information to print framework
168 // Otherwise report an error to the print framework
174 <p>The execution of {@link android.print.PrintDocumentAdapter#onLayout onLayout()} method can
177 method of the {@link android.print.PrintDocumentAdapter.LayoutResultCallback} object.</p>
181 {@link android.print.PrintDocumentAdapter.LayoutResultCallback#onLayoutFinished
183 since the last request. Setting this parameter properly allows the print framework to avoid
184 unnecessarily calling the {@link android.print.PrintDocumentAdapter#onWrite onWrite()} method,
185 essentially caching the previously written print document and improving performance.
188 <p>The main work of {@link android.print.PrintDocumentAdapter#onLayout onLayout()} is
192 determined by the print orientation:</p>
204 // Determine number of print items
212 <h3 id="write-file">Write a print document file</h3>
214 <p>When it is time to write print output to a file, the Android print framework calls the {@link
215 android.print.PrintDocumentAdapter#onWrite onWrite()} method of your application's {@link
216 android.print.PrintDocumentAdapter} class. The method's parameters specify which pages should be
219 call the {@link android.print.PrintDocumentAdapter.WriteResultCallback#onWriteFinished
223 <strong>Note:</strong> The Android print framework may call the {@link
224 android.print.PrintDocumentAdapter#onWrite onWrite()} method one or more times for every
225 call to {@link android.print.PrintDocumentAdapter#onLayout onLayout()}. For this reason, it is
227 {@link android.print.PrintDocumentAdapter.LayoutResultCallback#onLayoutFinished
228 onLayoutFinished()} method to {@code false} when the print content layout has not changed,
229 to avoid unnecessary re-writes of the print document.
234 {@link android.print.PrintDocumentAdapter.LayoutResultCallback#onLayoutFinished
236 since the last request. Setting this parameter properly allows the print framework to avoid
237 unnecessarily calling the {@link android.print.PrintDocumentAdapter#onLayout onLayout()} method,
238 essentially caching the previously written print document and improving performance.
243 android.print.pdf.PrintedPdfDocument} class to create a PDF file:</p>
289 // Signal the print framework the document is complete
300 <p>As with layout, execution of {@link android.print.PrintDocumentAdapter#onWrite onWrite()}
303 appropriate method of the {@link android.print.PrintDocumentAdapter.WriteResultCallback} object.
321 the Android print framework for printing. You can use any PDF generation library for this
322 purpose. This lesson shows how to use the {@link android.print.pdf.PrintedPdfDocument} class
325 <p>The {@link android.print.pdf.PrintedPdfDocument} class uses a {@link android.graphics.Canvas}
358 <strong>Tip:</strong> While the {@link android.graphics.Canvas} object allows you to place print
359 elements on the edge of a PDF document, many printers are not able to print to the edge of a
361 you build a print document with this class.