• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_Print
2
3## Overview
4
5Provides applications with the ability to access the printing system using CAPI.
6
7**Since:** 12
8
9## Summary
10
11### Type Definitions
12
13| Name | Description |
14| -------- | -------- |
15| [Print_StringList](#print_stringlist) | Printer device list. |
16| [Print_Property](#print_property) | Printer property. |
17| [Print_PropertyList](#print_propertylist) | Printer property list. |
18| [Print_Resolution](#print_resolution) | Print resolution unit. |
19| [Print_Margin](#print_margin) | Print margin. |
20| [Print_PageSize](#print_pagesize) | Print paper size. |
21| [Print_PrinterCapability](#print_printercapability) | Printer capability. |
22| [Print_DefaultValue](#print_defaultvalue) | Print default information. |
23| [Print_PrinterInfo](#print_printerinfo) | Printer information. |
24| [Print_PrintJob](#print_printjob) | Print job. |
25| [Print_Range](#print_range) | Print range. |
26| [Print_PrintAttributes](#print_printattributes) | Print attributes. |
27| [Print_WriteResultCallback](#print_writeresultcallback) | Write result callback. |
28| [Print_OnStartLayoutWrite](#print_onstartlayoutwrite) | Start layout callback. |
29| [Print_OnJobStateChanged](#print_onjobstatechanged) | Print job state callback. |
30| [Print_PrintDocCallback](#print_printdoccallback) | Print document state callback. |
31| [Print_PrinterDiscoveryCallback](#print_printerdiscoverycallback) | Printer discovery callback. |
32| [Print_PrinterChangeCallback](#print_printerchangecallback) | Printer state change callback. |
33
34### Enumerations
35
36| Name | Description |
37| -------- | -------- |
38| [Print_ErrorCode](#print_errorcode) | Error codes. |
39| [Print_PrinterState](#print_printerstate) | Printer state codes. |
40| [Print_DiscoveryEvent](#print_discoveryevent) | Printer discovery events. |
41| [Print_PrinterEvent](#print_printerevent) | Printer state change events. |
42| [Print_DuplexMode](#print_duplexmode) | Print duplex mode. |
43| [Print_ColorMode](#print_colormode) | Print color mode. |
44| [Print_OrientationMode](#print_orientationmode) | Print orientation. |
45| [Print_Quality](#print_quality) | Print quality. |
46| [Print_DocumentFormat](#print_documentformat) | Printer document format. |
47| [Print_JobDocAdapterState](#print_jobdocadapterstate) | Print job state. |
48
49### Functions
50
51| Name | Description |
52| -------- | -------- |
53| [OH_Print_Init](#oh_print_init) | Starts the print service, initializes the print client, and establishes a connection to the print service. |
54| [OH_Print_Release](#oh_print_release) | Closes the connection to the print service, unregisters callbacks, and releases print client resources. |
55| [OH_Print_StartPrinterDiscovery](#oh_print_startprinterdiscovery) | Starts printer discovery. |
56| [OH_Print_StopPrinterDiscovery](#oh_print_stopprinterdiscovery) | Stops printer discovery. |
57| [OH_Print_ConnectPrinter](#oh_print_connectprinter) | Connects to a printer using the printer ID. |
58| [OH_Print_StartPrintJob](#oh_print_startprintjob) | Starts a print job. |
59| [OH_Print_RegisterPrinterChangeListener](#oh_print_registerprinterchangelistener) | Registers a printer state change event listener. |
60| [OH_Print_UnregisterPrinterChangeListener](#oh_print_unregisterprinterchangelistener) | Unregisters the printer state change event listener. |
61| [OH_Print_QueryPrinterList](#oh_print_queryprinterlist) | Queries the printer list. |
62| [OH_Print_ReleasePrinterList](#oh_print_releaseprinterlist) | Releases the printer list. |
63| [OH_Print_QueryPrinterInfo](#oh_print_queryprinterinfo) | Queries printer information. |
64| [OH_Print_ReleasePrinterInfo](#oh_print_releaseprinterinfo) | Releases printer information memory. |
65| [OH_Print_LaunchPrinterManager](#oh_print_launchprintermanager) | Launches the printer manager window. |
66| [OH_Print_QueryPrinterProperties](#oh_print_queryprinterproperties) | Queries printer properties. |
67| [OH_Print_ReleasePrinterProperties](#oh_print_releaseprinterproperties) | Releases printer properties. |
68| [OH_Print_UpdatePrinterProperties](#oh_print_updateprinterproperties) | Updates printer properties. |
69| [OH_Print_RestorePrinterProperties](#oh_print_restoreprinterproperties) | Restores printer properties to default settings based on the property key list. |
70| [OH_Print_StartPrintByNative](#oh_print_startprintbynative) | Starts printing. |
71
72## Type Definitions
73
74### Print_StringList
75
76**Description**
77
78Printer device list.
79
80**Since:** 12
81
82| Member | Description |
83| ------------ | -------- |
84| count    | Number of strings. |
85| list | String pointer array.   |
86
87### Print_Property
88
89**Description**
90
91Printer property.
92
93**Since:** 12
94
95| Member | Description |
96| -------- | ----------------------- |
97| key | Property key. |
98| value | Property value. |
99
100### Print_PropertyList
101
102**Description**
103
104Printer property list.
105
106**Since:** 12
107
108| Member | Description |
109| ------------ | ------------ |
110| count | Number of properties. |
111| list | Property pointer array. |
112
113### Print_Resolution
114
115**Description**
116
117Print resolution unit.
118
119**Since:** 12
120
121| Parameter | Description |
122| ----------- | ---------- |
123| horizontalDpi | Horizontal resolution (dpi). |
124| verticalDpi | Vertical resolution (dpi). |
125
126### Print_Margin
127
128**Description**
129
130Print margin.
131
132**Since:** 12
133
134| Parameter | Description |
135| ----------- | ---------- |
136| leftMargin | Left margin (microns). |
137| topMargin | Top margin (microns). |
138| rightMargin | Right margin (microns). |
139| bottomMargin | Bottom margin (microns). |
140
141### Print_PageSize
142
143**Description**
144
145Print paper size.
146
147**Since:** 12
148
149| Parameter | Description |
150| ----------- | ---------- |
151| id | Paper ID. |
152| name | Paper name. |
153| width | Paper width (microns). |
154| height | Paper height (microns). |
155
156### Print_PrinterCapability
157
158**Description**
159
160Printer capability.
161
162**Since:** 12
163
164| Parameter | Description |
165| ----------- | ---------- |
166| supportedColorModes | Supported color modes list. |
167| supportedColorModesCount | Number of supported color modes. |
168| supportedDuplexModes | Supported duplex modes list. |
169| supportedDuplexModesCount | Number of supported duplex modes. |
170| supportedPageSizes | Supported paper sizes list. |
171| supportedPageSizesCount | Number of supported paper sizes. |
172| supportedMediaTypes | Supported media types (JSON string array format). |
173| supportedQualities | Supported print qualities list. |
174| supportedQualitiesCount | Number of supported print qualities. |
175| supportedPaperSources | Supported paper sources (JSON string array format). |
176| supportedCopies | Maximum supported copies. |
177| supportedResolutions | Supported resolutions list. |
178| supportedResolutionsCount | Number of supported resolutions. |
179| supportedOrientations | Supported orientations list. |
180| supportedOrientationsCount | Number of supported orientations. |
181| advancedCapability | Advanced capability (JSON format). |
182
183### Print_DefaultValue
184
185**Description**
186
187Printer default information.
188
189**Since:** 12
190
191| Parameter | Description |
192| ----------- | ---------- |
193| defaultColorMode | Default color mode. |
194| defaultDuplexMode | Default duplex mode. |
195| defaultMediaType | Default media type. |
196| defaultPageSizeId | Default paper size ID. |
197| defaultMargin | Default margin. |
198| defaultPaperSource | Default paper source. |
199| defaultPrintQuality | Default print quality. |
200| defaultCopies | Default number of copies. |
201| defaultResolution | Default resolution. |
202| defaultOrientation | Default orientation. |
203| otherDefaultValues | Other default values (JSON format). |
204
205### Print_PrinterInfo
206
207**Description**
208
209Printer information.
210
211**Since:** 12
212
213| Parameter | Description |
214| ----------- | ---------- |
215| printerState | Printer state. |
216| capability | Printer capability. |
217| defaultValue | Printer default properties. |
218| isDefaultPrinter | Whether it is the default printer. |
219| printerId | Printer ID. |
220| printerName | Printer name. |
221| description | Printer description. |
222| location | Printer location. |
223| makeAndModel | Printer manufacturer and model information. |
224| printerUri | Printer URI. |
225| detailInfo | Detailed information (JSON format). |
226
227### Print_PrintJob
228
229**Description**
230
231Print job.
232
233**Since:** 12
234
235| Parameter | Description |
236| ----------- | ---------- |
237| jobName | Print job name. |
238| fdList | Print file descriptor array. |
239| fdListCount | Number of print file descriptors. |
240| printerId | Printer ID. |
241| copyNumber | Number of copies. |
242| paperSource | Paper source. |
243| mediaType | Media type. |
244| pageSizeId | Paper size ID. |
245| colorMode | Color mode. |
246| duplexMode | Duplex mode. |
247| resolution | Resolution. |
248| printMargin | Print margin. |
249| borderless | Whether to print borderless. |
250| orientationMode | Print orientation. |
251| printQuality | Print quality. |
252| documentFormat | Document format. |
253| advancedOptions | Advanced options (JSON format). |
254
255### Print_Range
256
257**Description**
258
259Print range.
260
261**Since:** 13
262
263| Parameter | Description |
264| ----------- | ---------- |
265| startPage | Start page number. |
266| endPage | End page number. |
267| pagesArrayLen | Page array length. |
268| pagesArray | Page array. |
269
270### Print_PrintAttributes
271
272**Description**
273
274Print attributes.
275
276**Since:** 13
277
278| Parameter | Description |
279| ----------- | ---------- |
280| pageRange | Print range. |
281| pageSize | Paper size. |
282| pageMargin | Page margin. |
283| copyNumber | Number of copies. |
284| duplexMode | Duplex mode. |
285| colorMode | Color mode. |
286| isSequential | Whether to print sequentially. |
287| isLandscape | Whether to print in landscape. |
288| hasOption | Whether there are print options. |
289| options | Print options (256 bytes). |
290
291### Print_WriteResultCallback
292
293**Description**
294
295Write result callback.
296
297**Since:** 13
298
299**Parameters:**
300
301| Name | Description |
302| --------- | ---------- |
303| jobId | Print job ID. |
304| code | Write result status code. |
305
306### Print_OnStartLayoutWrite
307
308**Description**
309
310Start layout callback.
311
312**Since:** 13
313
314**Parameters:**
315
316| Name | Description |
317| --------- | ---------- |
318| jobId | Print job ID. |
319| fd | File descriptor. |
320| oldAttrs | Previous print attributes. |
321| newAttrs | Current print attributes. |
322| writeCallback | Write result callback function. |
323
324### Print_OnJobStateChanged
325
326**Description**
327
328Print job state change callback.
329
330**Since:** 13
331
332**Parameters:**
333
334| Name | Description |
335| --------- | ---------- |
336| jobId | Print job ID. |
337| state | Print job state. |
338
339### Print_PrintDocCallback
340
341**Description**
342
343Print document state callback.
344
345**Since:** 13
346
347| Parameter | Description |
348| ----------- | ---------- |
349| startLayoutWriteCb | Start layout write callback. |
350| jobStateChangedCb | Job state change callback. |
351
352### Print_PrinterDiscoveryCallback
353
354**Description**
355
356Printer discovery callback.
357
358**Since:** 12
359
360**Parameters:**
361
362| Name | Description |
363| --------- | ---------- |
364| event | Discovery event. |
365| printerInfo | Printer information. |
366
367### Print_PrinterChangeCallback
368
369**Description**
370
371Printer state change callback.
372
373**Since:** 12
374
375**Parameters:**
376
377| Name | Description |
378| --------- | ---------- |
379| event | Change event. |
380| printerInfo | Printer information. |
381
382## Enumerations
383
384### Print_ErrorCode
385
386**Description**
387
388Error codes.
389
390**Since:** 12
391
392| Enum Value | Description | Value |
393| -------- | -------- | -------- |
394| PRINT_ERROR_NONE | Operation successful. | 0 |
395| PRINT_ERROR_NO_PERMISSION | Permission verification failed. | 201 |
396| PRINT_ERROR_INVALID_PARAMETER | Invalid parameter. | 401 |
397| PRINT_ERROR_GENERIC_FAILURE | Generic internal error. | 24300001 |
398| PRINT_ERROR_RPC_FAILURE | RPC communication error. | 24300002 |
399| PRINT_ERROR_SERVER_FAILURE | Server error. | 24300003 |
400| PRINT_ERROR_INVALID_EXTENSION | Invalid extension. | 24300004 |
401| PRINT_ERROR_INVALID_PRINTER | Invalid printer. | 24300005 |
402| PRINT_ERROR_INVALID_PRINT_JOB | Invalid print job. | 24300006 |
403| PRINT_ERROR_FILE_IO | File I/O error. | 24300007 |
404| PRINT_ERROR_UNKNOWN | Unknown error. | 24300255 |
405
406### Print_PrinterState
407
408**Description**
409
410Printer state codes.
411
412**Since:** 12
413
414| Enum Value | Description |
415| -------- | -------- |
416| PRINTER_IDLE | Printer idle. |
417| PRINTER_BUSY | Printer busy. |
418| PRINTER_UNAVAILABLE | Printer unavailable. |
419
420### Print_DiscoveryEvent
421
422**Description**
423
424Printer discovery events.
425
426**Since:** 12
427
428| Enum Value | Description |
429| -------- | -------- |
430| PRINTER_DISCOVERED | Printer discovered. |
431| PRINTER_LOST | Printer lost. |
432| PRINTER_CONNECTING | Printer connecting. |
433| PRINTER_CONNECTED | Printer connected. |
434
435### Print_PrinterEvent
436
437**Description**
438
439Printer events.
440
441**Since:** 12
442
443| Enum Value | Description |
444| -------- | -------- |
445| PRINTER_ADDED | Printer added. |
446| PRINTER_DELETED | Printer deleted. |
447| PRINTER_STATE_CHANGED | Printer state changed. |
448| PRINTER_INFO_CHANGED | Printer information changed. |
449| PRINTER_PREFERENCE_CHANGED | Printer preference changed. |
450
451### Print_DuplexMode
452
453**Description**
454
455Print duplex mode.
456
457**Since:** 12
458
459| Enum Value | Description |
460| -------- | -------- |
461| DUPLEX_MODE_ONE_SIDED | One-sided printing. |
462| DUPLEX_MODE_TWO_SIDED_LONG_EDGE | Two-sided long edge printing. |
463| DUPLEX_MODE_TWO_SIDED_SHORT_EDGE | Two-sided short edge printing. |
464
465### Print_ColorMode
466
467**Description**
468
469Print color mode.
470
471**Since:** 12
472
473| Enum Value | Description |
474| -------- | -------- |
475| COLOR_MODE_MONOCHROME | Monochrome mode. |
476| COLOR_MODE_COLOR | Color mode. |
477| COLOR_MODE_AUTO | Auto mode. |
478
479### Print_OrientationMode
480
481**Description**
482
483Print orientation.
484
485**Since:** 12
486
487| Enum Value | Description |
488| -------- | -------- |
489| ORIENTATION_MODE_PORTRAIT | Portrait. |
490| ORIENTATION_MODE_LANDSCAPE | Landscape. |
491| ORIENTATION_MODE_REVERSE_LANDSCAPE | Reverse landscape. |
492| ORIENTATION_MODE_REVERSE_PORTRAIT | Reverse portrait. |
493| ORIENTATION_MODE_NONE | Not specified. |
494
495### Print_Quality
496
497**Description**
498
499Print quality.
500
501**Since:** 12
502
503| Enum Value | Description |
504| -------- | -------- |
505| PRINT_QUALITY_DRAFT | Draft quality. |
506| PRINT_QUALITY_NORMAL | Normal quality. |
507| PRINT_QUALITY_HIGH | High quality. |
508
509### Print_DocumentFormat
510
511**Description**
512
513Document format.
514
515**Since:** 12
516
517| Enum Value | Description | MIME Type |
518| -------- | -------- | -------- |
519| DOCUMENT_FORMAT_AUTO | Auto detect. | application/octet-stream. |
520| DOCUMENT_FORMAT_JPEG | JPEG image. | image/jpeg. |
521| DOCUMENT_FORMAT_PDF | PDF document. | application/pdf. |
522| DOCUMENT_FORMAT_POSTSCRIPT | PostScript document. | application/postscript. |
523| DOCUMENT_FORMAT_TEXT | Plain text. | text/plain. |
524
525### Print_JobDocAdapterState
526
527**Description**
528
529Print job document adapter state.
530
531**Since:** 13
532
533| Enum Value | Description |
534| -------- | -------- |
535| PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY | Print preview ability destroyed. |
536| PRINT_DOC_ADAPTER_PRINT_TASK_SUCCEED | Print task succeeded. |
537| PRINT_DOC_ADAPTER_PRINT_TASK_FAIL | Print task failed. |
538| PRINT_DOC_ADAPTER_PRINT_TASK_CANCEL | Print task canceled. |
539| PRINT_DOC_ADAPTER_PRINT_TASK_BLOCK | Print task blocked. |
540| PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_CANCELED | Preview ability destroyed due to cancellation. |
541| PRINT_DOC_ADAPTER_PREVIEW_ABILITY_DESTROY_FOR_STARTED | Preview ability destroyed due to task start. |
542
543## Function Documentation
544
545### OH_Print_Init()
546
547```cpp
548Print_ErrorCode OH_Print_Init();
549```
550
551**Description**
552
553Starts the print service, initializes the print client, and establishes a connection to the print service.
554
555**Permission:** ohos.permission.PRINT
556
557**System Capability:** SystemCapability.Print.PrintFramework
558
559**Since:** 12
560
561**Returns:**
562
563| Error Code | Description |
564| -------- | -------- |
565| PRINT_ERROR_NONE | Operation successful. |
566| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
567| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
568| PRINT_ERROR_SERVER_FAILURE | CUPS service failed to start. |
569
570### OH_Print_Release()
571
572```cpp
573Print_ErrorCode OH_Print_Release();
574```
575
576**Description**
577
578Closes the connection to the print service, unregisters callbacks, and releases print client resources.
579
580**System Capability:** SystemCapability.Print.PrintFramework
581
582**Since:** 12
583
584**Returns:**
585
586| Error Code | Description |
587| -------- | -------- |
588| PRINT_ERROR_NONE | Operation successful. |
589
590### OH_Print_StartPrinterDiscovery()
591
592```cpp
593Print_ErrorCode OH_Print_StartPrinterDiscovery(Print_PrinterDiscoveryCallback callback);
594```
595
596**Description**
597
598Starts the printer discovery process.
599
600**Permission:** ohos.permission.PRINT
601
602**System Capability:** SystemCapability.Print.PrintFramework
603
604**Since:** 12
605
606**Parameters:**
607
608| Name | Description |
609| -------- | -------- |
610| callback | Printer discovery event callback function. |
611
612**Returns:**
613
614| Error Code | Description |
615| -------- | -------- |
616| PRINT_ERROR_NONE | Operation successful. |
617| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
618| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
619| PRINT_ERROR_SERVER_FAILURE | Failed to query print extension list from BMS. |
620| PRINT_ERROR_INVALID_EXTENSION | No available print extensions found. |
621
622### OH_Print_StopPrinterDiscovery()
623
624```cpp
625Print_ErrorCode OH_Print_StopPrinterDiscovery();
626```
627
628**Description**
629
630Stops the printer discovery process.
631
632**Permission:** ohos.permission.PRINT
633
634**System Capability:** SystemCapability.Print.PrintFramework
635
636**Since:** 12
637
638**Returns:**
639
640| Error Code | Description |
641| -------- | -------- |
642| PRINT_ERROR_NONE | Operation successful. |
643| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
644| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
645
646### OH_Print_ConnectPrinter()
647
648```cpp
649Print_ErrorCode OH_Print_ConnectPrinter(const char *printerId);
650```
651
652**Description**
653
654Connects to a printer using the printer ID.
655
656**Permission:** ohos.permission.PRINT
657
658**System Capability:** SystemCapability.Print.PrintFramework
659
660**Since:** 12
661
662**Parameters:**
663
664| Name | Description |
665| -------- | -------- |
666| printerId | Printer ID to connect to. |
667
668**Returns:**
669
670| Error Code | Description |
671| -------- | -------- |
672| PRINT_ERROR_NONE | Operation successful. |
673| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
674| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
675| PRINT_ERROR_INVALID_PRINTER | Printer not in discovered list. |
676| PRINT_ERROR_SERVER_FAILURE | Unable to find extension responsible for the printer. |
677
678### OH_Print_StartPrintJob()
679
680```cpp
681Print_ErrorCode OH_Print_StartPrintJob(const Print_PrintJob *printJob);
682```
683
684**Description**
685
686Starts a print job.
687
688**Permission:** ohos.permission.PRINT
689
690**System Capability:** SystemCapability.Print.PrintFramework
691
692**Since:** 12
693
694**Parameters:**
695
696| Name | Description |
697| -------- | -------- |
698| printJob | Pointer to Print_PrintJob structure containing print job information. |
699
700**Returns:**
701
702| Error Code | Description |
703| -------- | -------- |
704| PRINT_ERROR_NONE | Operation successful. |
705| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
706| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
707| PRINT_ERROR_INVALID_PRINTER | Printer not in connected list. |
708| PRINT_ERROR_SERVER_FAILURE | Failed to create print job in print service. |
709| PRINT_ERROR_INVALID_PRINT_JOB | Unable to find job in job queue. |
710
711### OH_Print_RegisterPrinterChangeListener()
712
713```cpp
714Print_ErrorCode OH_Print_RegisterPrinterChangeListener(Print_PrinterChangeCallback callback);
715```
716
717**Description**
718
719Registers a printer state change listener.
720
721**Permission:** ohos.permission.PRINT
722
723**System Capability:** SystemCapability.Print.PrintFramework
724
725**Since:** 12
726
727**Parameters:**
728
729| Name | Description |
730| -------- | -------- |
731| callback | Printer state change callback function. |
732
733**Returns:**
734
735| Error Code | Description |
736| -------- | -------- |
737| PRINT_ERROR_NONE | Operation successful. |
738| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
739| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
740
741### OH_Print_UnregisterPrinterChangeListener()
742
743```cpp
744void OH_Print_UnregisterPrinterChangeListener();
745```
746
747**Description**
748
749Unregisters the printer state change listener.
750
751**Permission:** ohos.permission.PRINT
752
753**System Capability:** SystemCapability.Print.PrintFramework
754
755**Since:** 12
756
757### OH_Print_QueryPrinterList()
758
759```cpp
760Print_ErrorCode OH_Print_QueryPrinterList(Print_StringList *printerIdList);
761```
762
763**Description**
764
765Queries the list of added printers.
766
767**Permission:** ohos.permission.PRINT
768
769**System Capability:** SystemCapability.Print.PrintFramework
770
771**Since:** 12
772
773**Parameters:**
774
775| Name | Description |
776| -------- | -------- |
777| printerIdList | Pointer to Print_StringList to store the queried printer ID list. |
778
779**Returns:**
780
781| Error Code | Description |
782| -------- | -------- |
783| PRINT_ERROR_NONE | Operation successful. |
784| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
785| PRINT_ERROR_INVALID_PARAMETER | printerIdList is NULL. |
786| PRINT_ERROR_INVALID_PRINTER | Unable to query any connected printers. |
787| PRINT_ERROR_GENERIC_FAILURE | Unable to copy printer ID list. |
788
789### OH_Print_ReleasePrinterList()
790
791```cpp
792void OH_Print_ReleasePrinterList(Print_StringList *printerIdList);
793```
794
795**Description**
796
797Releases memory allocated for printer list query.
798
799**System Capability:** SystemCapability.Print.PrintFramework
800
801**Since:** 12
802
803**Parameters:**
804
805| Name | Description |
806| -------- | -------- |
807| printerIdList | Printer ID list to be released. |
808
809### OH_Print_QueryPrinterInfo()
810
811```cpp
812Print_ErrorCode OH_Print_QueryPrinterInfo(const char *printerId, Print_PrinterInfo **printerInfo);
813```
814
815**Description**
816
817Queries printer information based on printer ID.
818
819**Permission:** ohos.permission.PRINT
820
821**System Capability:** SystemCapability.Print.PrintFramework
822
823**Since:** 12
824
825**Parameters:**
826
827| Name | Description |
828| -------- | -------- |
829| printerId | Printer ID to query. |
830| printerInfo | Pointer to Print_PrinterInfo pointer to store printer information. |
831
832**Returns:**
833
834| Error Code | Description |
835| -------- | -------- |
836| PRINT_ERROR_NONE | Operation successful. |
837| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
838| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
839| PRINT_ERROR_INVALID_PARAMETER | printerId or printerInfo is NULL. |
840| PRINT_ERROR_INVALID_PRINTER | Unable to find printer in connected printer list. |
841
842### OH_Print_ReleasePrinterInfo()
843
844```cpp
845void OH_Print_ReleasePrinterInfo(Print_PrinterInfo *printerInfo);
846```
847
848**Description**
849
850Releases memory allocated for printer information query.
851
852**System Capability:** SystemCapability.Print.PrintFramework
853
854**Since:** 12
855
856**Parameters:**
857
858| Name | Description |
859| -------- | -------- |
860| printerInfo | Pointer to queried printer information to be released. |
861
862### OH_Print_LaunchPrinterManager()
863
864```cpp
865Print_ErrorCode OH_Print_LaunchPrinterManager();
866```
867
868**Description**
869
870Launches the system's printer management window.
871
872**System Capability:** SystemCapability.Print.PrintFramework
873
874**Since:** 12
875
876**Returns:**
877
878| Error Code | Description |
879| -------- | -------- |
880| PRINT_ERROR_NONE | Operation successful. |
881| PRINT_ERROR_GENERIC_FAILURE | Unable to launch printer manager window. |
882
883### OH_Print_QueryPrinterProperties()
884
885```cpp
886Print_ErrorCode OH_Print_QueryPrinterProperties(const char *printerId,
887                                              const Print_StringList *propertyKeyList,
888                                              Print_PropertyList *propertyList);
889```
890
891**Description**
892
893Queries printer property values based on property key list.
894
895**Permission:** ohos.permission.PRINT
896
897**System Capability:** SystemCapability.Print.PrintFramework
898
899**Since:** 12
900
901**Parameters:**
902
903| Name | Description |
904| -------- | -------- |
905| printerId | Printer ID to query. |
906| propertyKeyList | List of property keys to query. |
907| propertyList | List of queried printer property values. |
908
909**Returns:**
910
911| Error Code | Description |
912| -------- | -------- |
913| PRINT_ERROR_NONE | Operation successful. |
914| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
915| PRINT_ERROR_INVALID_PARAMETER | One of the parameters is NULL or key list is empty. |
916| PRINT_ERROR_INVALID_PRINTER | Printer properties for specified printer not found. |
917| PRINT_ERROR_GENERIC_FAILURE | Unable to copy printer properties. |
918
919### OH_Print_ReleasePrinterProperties()
920
921```cpp
922void OH_Print_ReleasePrinterProperties(Print_PropertyList *propertyList);
923```
924
925**Description**
926
927Releases memory allocated for printer properties query.
928
929**System Capability:** SystemCapability.Print.PrintFramework
930
931**Since:** 12
932
933**Parameters:**
934
935| Name | Description |
936| -------- | -------- |
937| propertyList | Pointer to queried printer properties to be released. |
938
939### OH_Print_UpdatePrinterProperties()
940
941```cpp
942Print_ErrorCode OH_Print_UpdatePrinterProperties(const char *printerId,
943                                               const Print_PropertyList *propertyList);
944```
945
946**Description**
947
948Sets printer properties based on property key-value pair list.
949
950**Permission:** ohos.permission.PRINT
951
952**System Capability:** SystemCapability.Print.PrintFramework
953
954**Since:** 12
955
956**Parameters:**
957
958| Name | Description |
959| -------- | -------- |
960| printerId | Printer ID to set. |
961| propertyList | List of printer property values to set. |
962
963**Returns:**
964
965| Error Code | Description |
966| -------- | -------- |
967| PRINT_ERROR_NONE | Operation successful. |
968| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
969| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
970
971### OH_Print_RestorePrinterProperties()
972
973```cpp
974Print_ErrorCode OH_Print_RestorePrinterProperties(const char *printerId,
975                                                const Print_StringList *propertyKeyList);
976```
977
978**Description**
979
980Restores printer properties to default settings based on property key list.
981
982**Permission:** ohos.permission.PRINT
983
984**System Capability:** SystemCapability.Print.PrintFramework
985
986**Since:** 12
987
988**Parameters:**
989
990| Name | Description |
991| -------- | -------- |
992| printerId | Printer ID to restore. |
993| propertyKeyList | List of property keys to restore. |
994
995**Returns:**
996
997| Error Code | Description |
998| -------- | -------- |
999| PRINT_ERROR_NONE | Operation successful. |
1000| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
1001| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |
1002
1003### OH_Print_StartPrintByNative()
1004
1005```cpp
1006Print_ErrorCode OH_Print_StartPrintByNative(const char *printJobName,
1007                                          Print_PrintDocCallback printDocCallback,
1008                                          void *context);
1009```
1010
1011**Description**
1012
1013Starts print service.
1014
1015**Permission:** ohos.permission.PRINT
1016
1017**System Capability:** SystemCapability.Print.PrintFramework
1018
1019**Since:** 13
1020
1021**Parameters:**
1022
1023| Name | Description |
1024| -------- | -------- |
1025| printJobName | Print job name. |
1026| printDocCallback | Print document state callback. |
1027| context | Caller application context. |
1028
1029**Returns:**
1030
1031| Error Code | Description |
1032| -------- | -------- |
1033| PRINT_ERROR_NONE | Operation successful. |
1034| PRINT_ERROR_NO_PERMISSION | Missing print permission. |
1035| PRINT_ERROR_RPC_FAILURE | Unable to connect to print service. |