printJob: redirect
Artikel
11/12/2021
4 Minuten Lesedauer
2 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Leiten Sie einen Druckauftrag an einen anderen Drucker um.
Das Umleiten eines Druckauftrags ist nur erfolgreich, wenn sich ein printTask-Vorgang in einem processing Zustand des zugeordneten Druckauftrags befindet, der durch einen Trigger gestartet wird, den die anfordernde App erstellt hat.
Ausführliche Informationen zur Verwendung dieser API zum Hinzufügen der Pull printing-Unterstützung für universelles Drucken 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 verwenden zu können, muss der Mandant des Benutzers oder der App über ein aktives Universal Print-Abonnement, eine Berechtigung zum Abrufen von Druckerzugriff und eine der in der folgenden Tabelle aufgeführten Berechtigungen verfügen.
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.Manage.All
HTTP-Anforderung
POST /print/printers/{printerId}/jobs/{printJobId}/redirect
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext die ID des Druckers an, zu dem der Druckauftrag umgeleitet werden soll.
Eigenschaft
Typ
Beschreibung
destinationPrinterId
Zeichenfolge
Die ID des Druckers, zu dem der Druckauftrag umgeleitet werden soll.
Konfiguration
microsoft.graph.printJobConfiguration
Die Konfiguration des Druckauftrags wurde aktualisiert.
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 200 OK Antwortcode und ein printJob-Objekt zurück, das für den Zieldrucker in die Warteschlange eingereiht ist.
Beispiele
Anforderung
POST https://graph.microsoft.com/v1.0/print/printers/{printerId}/jobs/{printJobId}/redirect
Content-Type: application/json
{
"destinationPrinterId": "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea",
"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 destinationPrinterId = "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea";
var 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}"]
.Redirect(destinationPrinterId,configuration)
.Request()
.PostAsync();
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 = {
destinationPrinterId: '9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea',
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}/redirect')
.post(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}/redirect"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *destinationPrinterId = @"9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea";
payloadDictionary[@"destinationPrinterId"] = destinationPrinterId;
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];
payloadDictionary[@"configuration"] = configuration;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
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();
String destinationPrinterId = "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea";
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;
graphClient.print().printers("{printerId}").jobs("{printJobId}")
.redirect(PrintJobRedirectParameterSet
.newBuilder()
.withDestinationPrinterId(destinationPrinterId)
.withConfiguration(configuration)
.build())
.buildRequest()
.post();
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('9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea')/jobs/$entity",
"id": "24123",
"createdDateTime": "2020-06-26T04:20:06.5715544Z",
"createdBy": {
"id": "",
"displayName": "",
"userPrincipalName": ""
},
"status": {
"state": "processing",
"description": "The print job is currently being processed by the printer.",
"details": ["interpreting"]
},
"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
}
}