printJob aktualisieren
Artikel
11/12/2021
4 Minuten Lesedauer
2 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Dient zum Aktualisieren eines Druckauftrags. Nur die Konfigurationseigenschaft kann aktualisiert werden.
Das Aktualisieren eines Druckauftrags ist nur erfolgreich, wenn der zugeordnete Druckauftrag einen PrintTask-Status processing aufgibt, der durch einen Trigger gestartet wird, den die anfordernde App erstellt hat. Ausführliche Informationen zum Registrieren eines Aufgabenauslösers finden Sie unter Extending Universal Print to support pull printing .
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Um den Universellen Druckdienst zu verwenden, muss der Mandant des Benutzers oder der App über ein aktives Universelles Druckabonnement verfügen, entweder die Anwendungsberechtigung Printer.Read.All oder Printer.ReadWrite.All und eine der in der folgenden Tabelle aufgeführten Berechtigungen.
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Nicht unterstützt
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt.
Anwendung
PrintJob.ReadWriteBasic.All, PrintJob.ReadWrite.All, PrintJob.Manage.All
HTTP-Anforderung
PATCH /print/printers/{printerId}/jobs/{printJobId}
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext die Werte der relevanten printJob-Felder an. Vorhandene Eigenschaften, die nicht im Anforderungstext enthalten sind, behalten ihre vorherigen Werte bei.
Nur die Konfigurationseigenschaft kann aktualisiert werden.
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 200 OK Antwortcode mit einem aktualisierten printJob-Objekt im Antworttext zurück.
Beispiele
Anforderung
PATCH https://graph.microsoft.com/v1.0/print/printers/{printerId}/jobs/{printJobId}
Content-Type: application/json
{
"configuration": {
"feedOrientation": "longEdgeFirst",
"pageRanges": [
{
"start": 1,
"end": 1
}
],
"quality": "medium",
"dpi": 600,
"orientation": "landscape",
"copies": 1,
"duplexMode": "oneSided",
"colorMode": "blackAndWhite",
"inputBin": "by-pass-tray",
"outputBin": "output-tray",
"mediaSize": "A4",
"margin": {
"top": 0,
"bottom": 0,
"left": 0,
"right": 0
},
"mediaType": "stationery",
"finishings": null,
"pagesPerSheet": 1,
"multipageLayout": "clockwiseFromBottomLeft",
"collate": false,
"scaling": "shrinkToFit",
"fitPdfToPage": false
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var printJob = new PrintJob
{
Configuration = new PrintJobConfiguration
{
FeedOrientation = PrinterFeedOrientation.LongEdgeFirst,
PageRanges = new List<IntegerRange>()
{
new IntegerRange
{
Start = 1,
End = 1
}
},
Quality = PrintQuality.Medium,
Dpi = 600,
Orientation = PrintOrientation.Landscape,
Copies = 1,
DuplexMode = PrintDuplexMode.OneSided,
ColorMode = PrintColorMode.BlackAndWhite,
InputBin = "by-pass-tray",
OutputBin = "output-tray",
MediaSize = "A4",
Margin = new PrintMargin
{
Top = 0,
Bottom = 0,
Left = 0,
Right = 0
},
MediaType = "stationery",
Finishings = null,
PagesPerSheet = 1,
MultipageLayout = PrintMultipageLayout.ClockwiseFromBottomLeft,
Collate = false,
Scaling = PrintScaling.ShrinkToFit,
FitPdfToPage = false
}
};
await graphClient.Print.Printers["{printer-id}"].Jobs["{printJob-id}"]
.Request()
.UpdateAsync(printJob);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const printJob = {
configuration: {
feedOrientation: 'longEdgeFirst',
pageRanges: [
{
start: 1,
end: 1
}
],
quality: 'medium',
dpi: 600,
orientation: 'landscape',
copies: 1,
duplexMode: 'oneSided',
colorMode: 'blackAndWhite',
inputBin: 'by-pass-tray',
outputBin: 'output-tray',
mediaSize: 'A4',
margin: {
top: 0,
bottom: 0,
left: 0,
right: 0
},
mediaType: 'stationery',
finishings: null,
pagesPerSheet: 1,
multipageLayout: 'clockwiseFromBottomLeft',
collate: false,
scaling: 'shrinkToFit',
fitPdfToPage: false
}
};
await client.api('/print/printers/{printerId}/jobs/{printJobId}')
.update(printJob);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/print/printers/{printerId}/jobs/{printJobId}"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphPrintJob *printJob = [[MSGraphPrintJob alloc] init];
MSGraphPrintJobConfiguration *configuration = [[MSGraphPrintJobConfiguration alloc] init];
[configuration setFeedOrientation: [MSGraphPrinterFeedOrientation longEdgeFirst]];
NSMutableArray *pageRangesList = [[NSMutableArray alloc] init];
MSGraphIntegerRange *pageRanges = [[MSGraphIntegerRange alloc] init];
[pageRanges setStart: 1];
[pageRanges setEnd: 1];
[pageRangesList addObject: pageRanges];
[configuration setPageRanges:pageRangesList];
[configuration setQuality: [MSGraphPrintQuality medium]];
[configuration setDpi: 600];
[configuration setOrientation: [MSGraphPrintOrientation landscape]];
[configuration setCopies: 1];
[configuration setDuplexMode: [MSGraphPrintDuplexMode oneSided]];
[configuration setColorMode: [MSGraphPrintColorMode blackAndWhite]];
[configuration setInputBin:@"by-pass-tray"];
[configuration setOutputBin:@"output-tray"];
[configuration setMediaSize:@"A4"];
MSGraphPrintMargin *margin = [[MSGraphPrintMargin alloc] init];
[margin setTop: 0];
[margin setBottom: 0];
[margin setLeft: 0];
[margin setRight: 0];
[configuration setMargin:margin];
[configuration setMediaType:@"stationery"];
[configuration setFinishings: null];
[configuration setPagesPerSheet: 1];
[configuration setMultipageLayout: [MSGraphPrintMultipageLayout clockwiseFromBottomLeft]];
[configuration setCollate: false];
[configuration setScaling: [MSGraphPrintScaling shrinkToFit]];
[configuration setFitPdfToPage: false];
[printJob setConfiguration:configuration];
NSError *error;
NSData *printJobData = [printJob getSerializedDataWithError:&error];
[urlRequest setHTTPBody:printJobData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
PrintJob printJob = new PrintJob();
PrintJobConfiguration configuration = new PrintJobConfiguration();
configuration.feedOrientation = PrinterFeedOrientation.LONG_EDGE_FIRST;
LinkedList<IntegerRange> pageRangesList = new LinkedList<IntegerRange>();
IntegerRange pageRanges = new IntegerRange();
pageRanges.start = 1L;
pageRanges.end = 1L;
pageRangesList.add(pageRanges);
configuration.pageRanges = pageRangesList;
configuration.quality = PrintQuality.MEDIUM;
configuration.dpi = 600;
configuration.orientation = PrintOrientation.LANDSCAPE;
configuration.copies = 1;
configuration.duplexMode = PrintDuplexMode.ONE_SIDED;
configuration.colorMode = PrintColorMode.BLACK_AND_WHITE;
configuration.inputBin = "by-pass-tray";
configuration.outputBin = "output-tray";
configuration.mediaSize = "A4";
PrintMargin margin = new PrintMargin();
margin.top = 0;
margin.bottom = 0;
margin.left = 0;
margin.right = 0;
configuration.margin = margin;
configuration.mediaType = "stationery";
configuration.finishings = null;
configuration.pagesPerSheet = 1;
configuration.multipageLayout = PrintMultipageLayout.CLOCKWISE_FROM_BOTTOM_LEFT;
configuration.collate = false;
configuration.scaling = PrintScaling.SHRINK_TO_FIT;
configuration.fitPdfToPage = false;
printJob.configuration = configuration;
graphClient.print().printers("{printerId}").jobs("{printJobId}")
.buildRequest()
.patch(printJob);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#print/printers('d5ef6ec4-07ca-4212-baf9-d45be126bfbb')/jobs/$entity",
"id": "44353",
"createdDateTime": "2020-06-26T04:20:06.5715544Z",
"createdBy": {
"id": "",
"displayName": "",
"userPrincipalName": ""
},
"status": {
"state": "paused",
"description": "The job is not a candidate for processing yet."
},
"configuration": {
"feedOrientation": "longEdgeFirst",
"pageRanges": [
{
"start": 1,
"end": 1
}
],
"quality": "medium",
"dpi": 600,
"orientation": "landscape",
"copies": 1,
"duplexMode": "oneSided",
"colorMode": "blackAndWhite",
"inputBin": "by-pass-tray",
"outputBin": "output-tray",
"mediaSize": "A4",
"margin": {
"top": 0,
"bottom": 0,
"left": 0,
"right": 0
},
"mediaType": "stationery",
"finishings": null,
"pagesPerSheet": 1,
"multipageLayout": "clockwiseFromBottomLeft",
"collate": false,
"scaling": "shrinkToFit",
"fitPdfToPage": false
}
}