사진 인쇄
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
사진을 찍고 공유하는 것은 휴대기기의 가장 흔한 용도입니다. 애플리케이션이
사진을 찍고 표시하거나 표시하거나 사용자가 이미지를 공유하도록 허용하는 경우 인쇄를 사용 설정하는 것이 좋습니다.
만들 수 있습니다 Android 지원 라이브러리는
최소한의 코드와 간단한 인쇄 레이아웃 옵션 집합을 제공합니다.
이 과정에서는 v4 지원 라이브러리 PrintHelper
클래스를 사용하여 이미지를 인쇄하는 방법을 보여줍니다.
이미지 인쇄
Android 지원 라이브러리 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)
}
}
}
자바
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 인쇄 사용자 인터페이스
표시되어 사용자가 프린터와 인쇄 옵션을 선택할 수 있습니다. 그런 다음 사용자는
작업을 취소할 수 있습니다. 사용자가 이미지 인쇄를 선택하면 인쇄 작업이 생성되고
인쇄 알림이 시스템 표시줄에 나타납니다.
인쇄물에 이미지 외에 추가 콘텐츠를 포함하려면
인쇄 문서를 구성할 수 있습니다. 인쇄 문서 만들기에 대한 자세한 내용은 다음을 참조하세요.
HTML 문서 인쇄 또는
맞춤 문서 인쇄
강의에 대해 알아보도록 하겠습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 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."]]