openharmony 鸿蒙 capi-ohprint-h

2026-08-25 浏览 (1)

ohprint.h

Overview

Declares APIs for discovering and connecting to printers, printing files, and querying the list of added printers and printer information.

File to include: <BasicServicesKit/ohprint.h>

Library: libohprint.so

System capability: SystemCapability.Print.PrintFramework

Since: 12

Related module: OH_Print

Summary

Structs

Nametypedef KeywordDescription
Print_StringListPrint_StringListDefines a struct for the string list.
Print_PropertyPrint_PropertyDefines a struct for the printer property.
Print_PropertyListPrint_PropertyListDefines a struct for the printer property list.
Print_ResolutionPrint_ResolutionDefines a struct for the printing resolution in dpi.
Print_MarginPrint_MarginDefines a struct for the page margin to print.
Print_PageSizePrint_PageSizeDefines a struct for the page size.
Print_PrinterCapabilityPrint_PrinterCapabilityDefines a struct for the printer capabilities.
Print_DefaultValuePrint_DefaultValueDefines a struct for the default property value.
Print_PrinterInfoPrint_PrinterInfoDefines a struct for the printer information.
Print_PrintJobPrint_PrintJobDefines a struct for the print job.
Print_RangePrint_RangeDefines a struct for the page range to print.
Print_PrintAttributesPrint_PrintAttributesDefines a struct for the print attributes.
Print_PrintDocCallbackPrint_PrintDocCallbackDefines a struct for the print job status callback.

Enums

Nametypedef KeywordDescription
Print_ErrorCodePrint_ErrorCodeEnumerates the error codes.
Print_PrinterStatePrint_PrinterStateEnumerates the printer states.
Print_DiscoveryEventPrint_DiscoveryEventEnumerates the printer discovery events.
Print_PrinterEventPrint_PrinterEventEnumerates the printer change events.
Print_DuplexModePrint_DuplexModeEnumerates the duplex modes.
Print_ColorModePrint_ColorModeEnumerates the color modes.
Print_OrientationModePrint_OrientationModeEnumerates the orientation modes.
Print_QualityPrint_QualityEnumerates the print qualities.
Print_DocumentFormatPrint_DocumentFormatEnumerates the MIME types.
Print_JobDocAdapterStatePrint_JobDocAdapterStateEnumerates the print job adapter states.
OH_Print_JobStateOH_Print_JobStateEnumerates the print job states.

Functions

Nametypedef KeywordDescription
typedef void(*Print_WriteResultCallback)(const char *jobId, uint32_t code)Print_WriteResultCallbackDefines a callback used to return the file write-back result.
typedef void(*Print_OnStartLayoutWrite)(const char *jobId, uint32_t fd, const Print_PrintAttributes *oldAttrs, const Print_PrintAttributes *newAttrs, Print_WriteResultCallback writeCallback)Print_OnStartLayoutWriteDefines a callback to be invoked when the file write-back starts.
typedef void(*Print_OnJobStateChanged)(const char *jobId, uint32_t state)Print_OnJobStateChangedDefines a callback to be invoked when the print job state changes.
typedef void (*Print_PrinterDiscoveryCallback)(Print_DiscoveryEvent event, const Print_PrinterInfo *printerInfo)Print_PrinterDiscoveryCallbackDefines a callback used to return the discovered printers.
typedef void (*Print_PrinterChangeCallback)(Print_PrinterEvent event, const Print_PrinterInfo *printerInfo)Print_PrinterChangeCallbackDefines a callback to be invoked when a printer is changed.
Print_ErrorCode OH_Print_Init()-Checks and starts the print service, initializes the print client, and connects it with the print service.
Print_ErrorCode OH_Print_Release()-Disconnects from the print service, dismisses the previous callback, and releases the print client resources.
Print_ErrorCode OH_Print_StartPrinterDiscovery(Print_PrinterDiscoveryCallback callback)-Starts printer discovery.
Print_ErrorCode OH_Print_StopPrinterDiscovery()-Stops printer discovery.
Print_ErrorCode OH_Print_ConnectPrinter(const char *printerId)-Connects to a printer by the printer ID.
Print_ErrorCode OH_Print_StartPrintJob(const Print_PrintJob *printJob)-Starts a print job.
Print_ErrorCode OH_Print_RegisterPrinterChangeListener(Print_PrinterChangeCallback callback)-Registers a listener for printer changes.
void OH_Print_UnregisterPrinterChangeListener()-Unregisters this listener for printer changes.
Print_ErrorCode OH_Print_QueryPrinterList(Print_StringList *printerIdList)-Queries the list of added printers.
void OH_Print_ReleasePrinterList(Print_StringList *printerIdList)-Releases the memory used to query the printer list.
Print_ErrorCode OH_Print_QueryPrinterInfo(const char *printerId, Print_PrinterInfo **printerInfo)-Queries printer information by printer ID.
void OH_Print_ReleasePrinterInfo(Print_PrinterInfo *printerInfo)-Releases the memory used to query the printer information.
Print_ErrorCode OH_Print_LaunchPrinterManager()-Starts the printer management window of the system.
Print_ErrorCode OH_Print_QueryPrinterProperties(const char *printerId, const Print_StringList *propertyKeyList, Print_PropertyList *propertyList)-Queries the printer properties based on the list of property keys.
void OH_Print_ReleasePrinterProperties(Print_PropertyList *propertyList)-Releases the memory used to query the printer properties.
Print_ErrorCode OH_Print_UpdatePrinterProperties(const char *printerId, const Print_PropertyList *propertyList)-Updates the printer properties based on the KV pairs.
Print_ErrorCode OH_Print_RestorePrinterProperties(const char *printerId, const Print_StringList *propertyKeyList)-Restores printer properties to the default settings based on the property key list.
Print_ErrorCode OH_Print_StartPrintByNative(const char *printJobName, Print_PrintDocCallback printDocCallback, void *context)-Starts the printing dialog box.
typedef void(*OH_Print_OnJobStateChanged)(const char *jobId, OH_Print_JobState state)-Defines a callback to be invoked when the print job state changes.
Print_ErrorCode OH_Print_StartPrintWithJobStateCallback(const Print_PrintJob *printJob, OH_Print_OnJobStateChanged jobStateChangedCb)-Starts a print job with the callback to be invoked when the print job state changes.

Enum Description

Print_ErrorCode

enum Print_ErrorCode

Description

Enumerates the error codes.

Since: 12

Enum ItemDescription
PRINT_ERROR_NONE = 0Operation successful.
PRINT_ERROR_NO_PERMISSION = 201Permission verification failed.
PRINT_ERROR_INVALID_PARAMETER = 401Invalid parameter.
PRINT_ERROR_GENERIC_FAILURE = 24300001Internal error.
PRINT_ERROR_RPC_FAILURE = 24300002RPC communication error.
PRINT_ERROR_SERVER_FAILURE = 24300003Server error.
PRINT_ERROR_INVALID_EXTENSION = 24300004Invalid extension.
PRINT_ERROR_INVALID_PRINTER = 24300005Invalid printer.
PRINT_ERROR_INVALID_PRINT_JOB = 24300006Invalid print job.
PRINT_ERROR_FILE_IO = 24300007File I/O error.
PRINT_ERROR_UNKNOWN = 24300255Unknown error.

Print_PrinterState

enum Print_PrinterState

Description

Enumerates the printer states.

Since: 12

Enum ItemDescription
PRINTER_IDLEThe printer is idle.
PRINTER_BUSYThe printer is busy.
PRINTER_UNAVAILABLEThe printer is unavailable.

Print_DiscoveryEvent

enum Print_DiscoveryEvent

Description

Enumerates the printer discovery events.

Since: 12

Enum ItemDescription
PRINTER_DISCOVERED = 0Printer discovered.
PRINTER_LOST = 1Printer lost.
PRINTER_CONNECTING = 2Printer connecting.
PRINTER_CONNECTED = 3Printer connected.

Print_PrinterEvent

enum Print_PrinterEvent

Description

Enumerates the printer change events.

Since: 12

Enum ItemDescription
PRINTER_ADDED = 0Printer added.
PRINTER_DELETED = 1Printer deleted.
PRINTER_STATE_CHANGED = 2Printer changed.
PRINTER_INFO_CHANGED = 3Printer information changed.

Print_DuplexMode

enum Print_DuplexMode

Description

Enumerates the duplex modes.

Since: 12

Enum ItemDescription
DUPLEX_MODE_ONE_SIDED = 0Single-sided mode.
DUPLEX_MODE_TWO_SIDED_LONG_EDGE = 1Duplex mode with flipping on long edge.
DUPLEX_MODE_TWO_SIDED_SHORT_EDGE = 2Duplex mode with flipping on short edge.

Print_ColorMode

enum Print_ColorMode

Description

Enumerates the color modes.

Since: 12

Enum ItemDescription
COLOR_MODE_MONOCHROME = 0B/W mode.
COLOR_MODE_COLOR = 1Color mode.
COLOR_MODE_AUTO = 2Auto mode.

Print_OrientationMode

enum Print_OrientationMode

Description

Enumerates the orientation modes.

Since: 12

Enum ItemDescription
ORIENTATION_MODE_PORTRAIT = 0Portrait mode.
ORIENTATION_MODE_LANDSCAPE = 1Landscape mode.
ORIENTATION_MODE_REVERSE_LANDSCAPE = 2Reverse landscape mode.
ORIENTATION_MODE_REVERSE_PORTRAIT = 3Reverse portrait mode.
ORIENTATION_MODE_NONE = 4Not specified.

Print_Quality

enum Print_Quality

Description

Enumerates the print qualities.

Since: 12

Enum ItemDescription
PRINT_QUALITY_DRAFT = 3Draft.
PRINT_QUALITY_NORMAL = 4Normal quality.
PRINT_QUALITY_HIGH = 5High quality.

Print_DocumentFormat

enum Print_DocumentFormat

Description

Enumerates the MIME types.

Since: 12

Enum ItemDescription
DOCUMENT_FORMAT_AUTOapplication/octet-stream.
DOCUMENT_FORMAT_JPEGimage/jpeg.
DOCUMENT_FORMAT_PDFapplication/pdf.
DOCUMENT_FORMAT_POSTSCRIPTapplication/postscript.
DOCUMENT_FORMAT_TEXTtext/plain.

Print_JobDocAdapterState

enum Print_JobDocAdapterState

Description

Enumerates the print job adapter states.

Since: 13

Enum ItemDescription
PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY = 0Print job preview destroyed.
PRINT_DOC_ADAPTER_PRINT_TASK_SUCCEED = 1Successful print job.
PRINT_DOC_ADAPTER_PRINT_TASK_FAIL = 2Print job failed.
PRINT_DOC_ADAPTER_PRINT_TASK_CANCEL = 3Print job canceled.
PRINT_DOC_ADAPTER_PRINT_TASK_BLOCK = 4Print job blocked.
PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_CANCELED = 5Print job preview destroyed due to cancellation.
PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_STARTED = 6Print job preview destroyed due to startup.

OH_Print_JobState

enum OH_Print_JobState

Description

Enumerates the print job states.

Since: 24

NameValueDescription
OH_PRINT_JOB_SUCCEED0Successful print job.
OH_PRINT_JOB_FAIL1Print job failed.
OH_PRINT_JOB_CANCEL2Print job canceled.
OH_PRINT_JOB_BLOCK3Print job blocked.

Function Description

Print_WriteResultCallback()

typedef void(*Print_WriteResultCallback)(const char *jobId, uint32_t code)

Description

Defines a callback used to return the file write-back result.

Since: 13

Parameters

NameDescription
const char *jobIdPointer to the print job ID.
uint32_t codeFile write-back result.

Print_OnStartLayoutWrite()

typedef void(*Print_OnStartLayoutWrite)(const char *jobId, uint32_t fd, const Print_PrintAttributes *oldAttrs, const Print_PrintAttributes *newAttrs, Print_WriteResultCallback writeCallback)

Description

Defines a callback to be invoked when the file write-back starts.

Since: 13

Parameters

NameDescription
const char *jobIdPointer to the print job ID.
uint32_t fdFile descriptor to write.
const Print_PrintAttributes *oldAttrsPointer to the old attribute.
const Print_PrintAttributes *newAttrsPointer to the new attribute.
Print_WriteResultCallback writeCallbackDefines a callback used to return the file write-back result.

Print_OnJobStateChanged()

typedef void(*Print_OnJobStateChanged)(const char *jobId, uint32_t state)

Description

Defines a callback to be invoked when the print job state changes.

Since: 13

Parameters

NameDescription
const char *jobIdPointer to the print job ID.
uint32_t statePrint job state.

Print_PrinterDiscoveryCallback()

typedef void (*Print_PrinterDiscoveryCallback)(Print_DiscoveryEvent event, const Print_PrinterInfo *printerInfo)

Description

Defines a callback used to return the discovered printers.

Since: 12

Parameters

NameDescription
Print_DiscoveryEvent eventPrinter discovery event.
const Print_PrinterInfo *printerInfoPrinter information when the discovery event occurs.

Print_PrinterChangeCallback()

typedef void (*Print_PrinterChangeCallback)(Print_PrinterEvent event, const Print_PrinterInfo *printerInfo)

Description

Defines a callback to be invoked when a printer is changed.

Since: 12

Parameters

NameDescription
Print_PrinterEvent eventPrinter change event during the running of the print service.
const Print_PrinterInfo *printerInfoPrinter information when the change event occurs.

OH_Print_Init()

Print_ErrorCode OH_Print_Init()

Description

Checks and starts the print service, initializes the print client, and connects it with the print service.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.
PRINT_ERROR_SERVER_FAILURE: Failed to start the CUPS service.

OH_Print_Release()

Print_ErrorCode OH_Print_Release()

Description

Disconnects from the print service, dismisses the previous callback, and releases the print client resources.

System capability: SystemCapability.Print.PrintFramework

Since: 12

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
Currently, no other error codes will be returned.

OH_Print_StartPrinterDiscovery()

Print_ErrorCode OH_Print_StartPrinterDiscovery(Print_PrinterDiscoveryCallback callback)

Description

Starts printer discovery.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
Print_PrinterDiscoveryCallback callbackPrint_PrinterDiscoveryCallback to be invoked when a printer is discovered.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.
PRINT_ERROR_SERVER_FAILURE: Failed to query the print extension list from the BMS.
PRINT_ERROR_INVALID_EXTENSION: No available print extension is found.

OH_Print_StopPrinterDiscovery()

Print_ErrorCode OH_Print_StopPrinterDiscovery()

Description

Stops printer discovery.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.

OH_Print_ConnectPrinter()

Print_ErrorCode OH_Print_ConnectPrinter(const char *printerId)

Description

Connects to a printer by the printer ID.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const char *printerIdPointer to the ID of the printer to be connected.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.
PRINT_ERROR_INVALID_PRINTER: Printer does not exist in the list of discovered printers.
PRINT_ERROR_SERVER_FAILURE: Failed to find the printer extension.

OH_Print_StartPrintJob()

Print_ErrorCode OH_Print_StartPrintJob(const Print_PrintJob *printJob)

Description

Starts a print job.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const Print_PrintJob *printJobPointer to the Print_PrintJob instance of the specified print job information.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.
PRINT_ERROR_INVALID_PRINTER: Printer does not exist in the list of connected printers.
PRINT_ERROR_SERVER_FAILURE: Failed to create a print job in the print service.
PRINT_ERROR_INVALID_PRINT_JOB: Failed to find the specified task in the task queue.

OH_Print_RegisterPrinterChangeListener()

Print_ErrorCode OH_Print_RegisterPrinterChangeListener(Print_PrinterChangeCallback callback)

Description

Registers a listener for printer changes.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
Print_PrinterChangeCallback callbackPrint_PrinterChangeCallback to be registered.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.

OH_Print_UnregisterPrinterChangeListener()

void OH_Print_UnregisterPrinterChangeListener()

Description

Unregisters this listener for printer changes.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

OH_Print_QueryPrinterList()

Print_ErrorCode OH_Print_QueryPrinterList(Print_StringList *printerIdList)

Description

Queries the list of added printers.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
Print_StringList *printerIdListPointer to the Print_StringList instance that stores the queried printer ID list.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_INVALID_PARAMETER: printerIdList is null.
PRINT_ERROR_INVALID_PRINTER: Failed to query any connected printers.
PRINT_ERROR_GENERIC_FAILURE: Failed to copy printer ID list.

OH_Print_ReleasePrinterList()

void OH_Print_ReleasePrinterList(Print_StringList *printerIdList)

Description

Releases the memory used to query the printer list.

System capability: SystemCapability.Print.PrintFramework

Since: 12

Parameters

NameDescription
Print_StringList *printerIdListPointer to the queried printer ID list.

OH_Print_QueryPrinterInfo()

Print_ErrorCode OH_Print_QueryPrinterInfo(const char *printerId, Print_PrinterInfo **printerInfo)

Description

Queries printer information by printer ID.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const char *printerIdPointer to the printer ID to be queried.
Print_PrinterInfo **printerInfoDouble pointer to the Print_PrinterInfo.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.
PRINT_ERROR_INVALID_PARAMETER: The printerId or printerInfo is null.
PRINT_ERROR_INVALID_PRINTER: Failed to find the specified printer in the list of connected printers.

OH_Print_ReleasePrinterInfo()

void OH_Print_ReleasePrinterInfo(Print_PrinterInfo *printerInfo)

Description

Releases the memory used to query the printer information.

System capability: SystemCapability.Print.PrintFramework

Since: 12

Parameters

NameDescription
Print_PrinterInfo *printerInfoPointer to the queried printer information.

OH_Print_LaunchPrinterManager()

Print_ErrorCode OH_Print_LaunchPrinterManager()

Description

Starts the printer management window of the system.

System capability: SystemCapability.Print.PrintFramework

Since: 12

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_GENERIC_FAILURE: Failed to start the printer management window.

OH_Print_QueryPrinterProperties()

Print_ErrorCode OH_Print_QueryPrinterProperties(const char *printerId, const Print_StringList *propertyKeyList, Print_PropertyList *propertyList)

Description

Queries the printer properties based on the list of property keys.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const char *printerIdPointer to the printer ID to be queried.
const Print_StringList *propertyKeyListPointer to the list of property keys.
Print_PropertyList *propertyListPointer to the queried printer properties.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_INVALID_PARAMETER: One of the parameters is null or the key list is empty.
PRINT_ERROR_INVALID_PRINTER: Failed to find properties of the specified printer.
PRINT_ERROR_GENERIC_FAILURE: Failed to copy printer properties.

OH_Print_ReleasePrinterProperties()

void OH_Print_ReleasePrinterProperties(Print_PropertyList *propertyList)

Description

Releases the memory used to query the printer properties.

System capability: SystemCapability.Print.PrintFramework

Since: 12

Parameters

NameDescription
Print_PropertyList *propertyListPointer to the queried printer properties.

OH_Print_UpdatePrinterProperties()

Print_ErrorCode OH_Print_UpdatePrinterProperties(const char *printerId, const Print_PropertyList *propertyList)

Description

Updates the printer properties based on the KV pairs.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const char *printerIdPointer to the printer ID.
const Print_PropertyList *propertyListPointer to the list of printer properties to be updated.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.

OH_Print_RestorePrinterProperties()

Print_ErrorCode OH_Print_RestorePrinterProperties(const char *printerId, const Print_StringList *propertyKeyList)

Description

Restores printer properties to the default settings based on the property key list.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 12

Parameters

NameDescription
const char *printerIdPointer to the printer ID.
const Print_StringList *propertyKeyListPointer to the property key list.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.

OH_Print_StartPrintByNative()

Print_ErrorCode OH_Print_StartPrintByNative(const char *printJobName, Print_PrintDocCallback printDocCallback, void *context)

Description

Starts the printing dialog box.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 13

Parameters

NameDescription
const char *printJobNamePointer to the name of the print job.
Print_PrintDocCallback printDocCallbackCallback used to return the file state.
void *contextPointer to the context of the caller.

Returns

TypeDescription
Print_ErrorCodePRINT_ERROR_NONE: Operation is successful.
PRINT_ERROR_NO_PERMISSION: The ohos.permission.PRINT permission is required.
PRINT_ERROR_RPC_FAILURE: Failed to connect to the print service.

OH_Print_OnJobStateChanged()

typedef void(*OH_Print_OnJobStateChanged)(const char *jobId, OH_Print_JobState state)

Description

Defines a callback to be invoked when the print job state changes.

Since: 24

Parameters

NameDescription
const char *jobIdPointer to the print job ID.
OH_Print_JobState statePrint job state.

OH_Print_StartPrintWithJobStateCallback()

Print_ErrorCode OH_Print_StartPrintWithJobStateCallback(const Print_PrintJob *printJob, OH_Print_OnJobStateChanged jobStateChangedCb)

Description

Starts a print job with the callback to be invoked when the print job state changes.

System capability: SystemCapability.Print.PrintFramework

Required permissions: ohos.permission.PRINT

Since: 24

Parameters

NameDescription
const Print_PrintJob *printJobPointer to the print job struct.
OH_Print_OnJobStateChanged jobStateChangedCbCallback to be invoked when the print job state changes.

Returns

NameValueDescription
PRINT_ERROR_NONE0Operation is successful.
PRINT_ERROR_NO_PERMISSION201The ohos.permission.PRINT permission is required.
PRINT_ERROR_INVALID_PARAMETER401One of the parameters is null or the key list is empty.
PRINT_ERROR_GENERIC_FAILURE24300001The callback function cannot be copied.
PRINT_ERROR_RPC_FAILURE24300002Failed to connect to the print service.
PRINT_ERROR_SERVER_FAILURE24300003The print job struct cannot be created in the print service.
PRINT_ERROR_INVALID_PRINTER24300005The properties of the specified printer cannot be found.
PRINT_ERROR_INVALID_PRINT_JOB24300006Print job cannot be found in the job queue.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 errorcode-zlib

openharmony 鸿蒙 capi-oh-scan-scan-picturescanprogress

openharmony 鸿蒙 js-apis-screen-lock

openharmony 鸿蒙 capi-os-account-common-h

openharmony 鸿蒙 js-apis-screen-lock-sys

openharmony 鸿蒙 capi-oh-print-print-propertylist

openharmony 鸿蒙 capi-oh-scan

openharmony 鸿蒙 js-apis-system-device

openharmony 鸿蒙 errorcode-intelligentVoice

openharmony 鸿蒙 js-apis-request-sys

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/OKaGsGPJ