फ़ोटो प्रिंट करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
फ़ोटो लेना और शेयर करना मोबाइल डिवाइस के सबसे लोकप्रिय इस्तेमाल में से एक है. अगर आपका आवेदन
फ़ोटो लेता है, उन्हें दिखाता है या उपयोगकर्ताओं को इमेज शेयर करने की सुविधा देता है, तो आपको प्रिंटिंग चालू करने की सुविधा चालू करनी चाहिए
आपके ऐप्लिकेशन में मौजूद उन इमेज को शामिल करता है. Android सपोर्ट लाइब्रेरी, कीबोर्ड का इस्तेमाल करके इमेज प्रिंटिंग की सुविधा चालू करने का आसान फ़ंक्शन देती है
कोड की कम से कम संख्या और प्रिंट लेआउट के विकल्पों का सामान्य सेट.
इस लेसन में, v4 सहायता लाइब्रेरी PrintHelper
क्लास का इस्तेमाल करके इमेज को प्रिंट करने का तरीका बताया गया है.
इमेज प्रिंट करना
Android Support Library PrintHelper
क्लास से मिलती है
प्रिंट करने का आसान तरीक़ा बताया है. क्लास के लिए एक लेआउट विकल्प होता है, setScaleMode()
,
जो आपको दो में से एक विकल्प से प्रिंट करने की सुविधा देता है:
SCALE_MODE_FIT
- यह
विकल्प से इमेज का साइज़ तय होता है. इससे पेज के प्रिंट किए जा सकने वाले हिस्से में पूरी इमेज दिखती है.
SCALE_MODE_FILL
- यह
विकल्प इमेज को स्केल करता है, ताकि यह पेज के प्रिंट किए जा सकने वाले पूरे हिस्से में भर जाए. इसे चुना जा रहा है
सेटिंग का मतलब है कि इमेज के ऊपर और नीचे का कुछ हिस्सा या बाएं और दाएं किनारे का कुछ हिस्सा
प्रिंट नहीं किया गया. स्केल मोड सेट न करने पर, यह विकल्प डिफ़ॉल्ट वैल्यू के तौर पर सेट हो जाता है.
setScaleMode()
के लिए स्केलिंग के दोनों विकल्प, इमेज के मौजूदा आसपेक्ट रेशियो को बनाए रखते हैं. कोड का यह उदाहरण
PrintHelper
क्लास का इंस्टेंस बनाने का तरीका दिखाता है,
स्केलिंग विकल्प पर क्लिक करें और प्रिंट करने की प्रक्रिया शुरू करें:
Kotlin
private fun doPhotoPrint() {
activity?.also { context ->
PrintHelper(context).apply {
scaleMode = PrintHelper.SCALE_MODE_FIT
}.also { printHelper ->
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.droids)
printHelper.printBitmap("droids.jpg - test print", bitmap)
}
}
}
Java
private void doPhotoPrint() {
PrintHelper photoPrinter = new PrintHelper(getActivity());
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.droids);
photoPrinter.printBitmap("droids.jpg - test print", bitmap);
}
इस तरीके को मेन्यू आइटम के लिए कार्रवाई के तौर पर कॉल किया जा सकता है. ध्यान दें कि ऐसी कार्रवाइयों के लिए मेन्यू आइटम
हमेशा समर्थित नहीं (जैसे कि प्रिंटिंग) को ओवरफ़्लो मेनू में नहीं रखा जाना चाहिए. ज़्यादा के लिए
जानकारी के लिए, कार्रवाई बार डिज़ाइन देखें
पढ़ें.
printBitmap()
तरीका के बाद, यह
कॉल किया गया है, तो आपको अपने आवेदन से कोई अन्य कार्रवाई करने की आवश्यकता नहीं है. Android प्रिंट का यूज़र इंटरफ़ेस
दिखाई देता है, जो उपयोगकर्ता को प्रिंटर और प्रिंटिंग के विकल्पों को चुनने की अनुमति देता है. इसके बाद उपयोगकर्ता,
इमेज जोड़ें या कार्रवाई रद्द करें. अगर उपयोगकर्ता इमेज को प्रिंट करता है, तो एक प्रिंट जॉब बन जाता है और
प्रिंट करने की सूचना, सिस्टम बार में दिखती है.
अगर आपको अपने प्रिंटआउट में सिर्फ़ इमेज के अलावा, अतिरिक्त कॉन्टेंट शामिल करना है, तो
एक प्रिंट दस्तावेज़ बनाएं. प्रिंट करने के लिए दस्तावेज़ बनाने के बारे में जानकारी के लिए, देखें
एचटीएमएल दस्तावेज़ प्रिंट करना या
कस्टम दस्तावेज़ प्रिंट करना
लेसन.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Printing photos\n\nTaking and sharing photos is one of the most popular uses for mobile devices. If your application\ntakes photos, displays them, or allows users to share images, you should consider enabling printing\nof those images in your application. The [Android Support Library](/tools/support-library) provides a convenient function for enabling image printing using a\nminimal amount of code and simple set of print layout options.\n\nThis lesson shows you how to print an image using the v4 support library [PrintHelper](/reference/androidx/print/PrintHelper) class.\n\nPrint an image\n--------------\n\nThe Android Support Library [PrintHelper](/reference/androidx/print/PrintHelper) class provides\na simple way to print images. The class has a single layout option, [setScaleMode()](/reference/androidx/print/PrintHelper#setScaleMode(int)),\nwhich allows you to print with one of two options:\n\n- [SCALE_MODE_FIT](/reference/androidx/print/PrintHelper#SCALE_MODE_FIT) - This option sizes the image so that the whole image is shown within the printable area of the page.\n- [SCALE_MODE_FILL](/reference/androidx/print/PrintHelper#SCALE_MODE_FILL) - This option scales the image so that it fills the entire printable area of the page. Choosing this setting means that some portion of the top and bottom, or left and right edges of the image is not printed. This option is the default value if you do not set a scale mode.\n\nBoth scaling options for [setScaleMode()](/reference/androidx/print/PrintHelper#setScaleMode(int)) keep the existing aspect ratio of the image intact. The following code example\nshows how to create an instance of the [PrintHelper](/reference/androidx/print/PrintHelper) class, set the\nscaling option, and start the printing process: \n\n### Kotlin\n\n```kotlin\nprivate fun doPhotoPrint() {\n activity?.also { context -\u003e\n PrintHelper(context).apply {\n scaleMode = PrintHelper.SCALE_MODE_FIT\n }.also { printHelper -\u003e\n val bitmap = BitmapFactory.decodeResource(resources, R.drawable.droids)\n printHelper.printBitmap(\"droids.jpg - test print\", bitmap)\n }\n }\n}\n```\n\n### Java\n\n```java\nprivate void doPhotoPrint() {\n PrintHelper photoPrinter = new PrintHelper(getActivity());\n photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);\n Bitmap bitmap = BitmapFactory.decodeResource(getResources(),\n R.drawable.droids);\n photoPrinter.printBitmap(\"droids.jpg - test print\", bitmap);\n}\n```\n\n\nThis method can be called as the action for a menu item. Note that menu items for actions that are\nnot always supported (such as printing) should be placed in the overflow menu. For more\ninformation, see the [Action Bar](/design/patterns/actionbar) design\nguide.\n\nAfter the [printBitmap()](/reference/androidx/print/PrintHelper#printBitmap(java.lang.String, android.graphics.Bitmap)) method is\ncalled, no further action from your application is required. The Android print user interface\nappears, allowing the user to select a printer and printing options. The user can then print the\nimage or cancel the action. If the user chooses to print the image, a print job is created and a\nprinting notification appears in the system bar.\n\nIf you want to include additional content in your printouts beyond just an image, you must\nconstruct a print document. For information on creating documents for printing, see the\n[Printing an HTML document](/training/printing/html-docs) or\n[Printing a custom document](/training/printing/custom-docs)\nlessons."]]