printJob:重定向
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
将 打印作业 重定向到其他 打印机 。
仅当关联打印作业上的 printTask 处于 processing
状态(由请求应用创建的触发器启动)时,重定向打印作业才会成功。
有关如何使用此 API 向通用打印添加拉取打印支持的详细信息,请参阅 扩展通用打印以支持拉取打印 。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
❌
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时 ,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型 。 要了解有关这些权限的详细信息,请参阅 权限参考 。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
不支持。
不支持。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
PrintJob.Manage.All
不可用。
HTTP 请求
POST /print/printers/{id}/jobs/{id}/redirect
名称
说明
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
请求正文
在请求正文中,提供打印作业应重定向到的打印机 ID。
属性
类型
说明
destinationPrinterId
String
打印作业应重定向到的打印机的 ID。
configuration
microsoft.graph.printJobConfiguration
更新了打印作业的配置。
响应
如果成功,此方法将 200 OK
返回响应代码和为目标打印机排队的 printJob 对象。
示例
以下示例演示如何调用此 API。
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/print/printers/d5ef6ec4-07ca-4212-baf9-d45be126bfbb/jobs/44353/redirect
{
"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
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Print.Printers.Item.Jobs.Item.Redirect;
using Microsoft.Graph.Beta.Models;
var requestBody = new RedirectPostRequestBody
{
DestinationPrinterId = "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea",
Configuration = new PrintJobConfiguration
{
FeedOrientation = PrinterFeedOrientation.LongEdgeFirst,
PageRanges = new List<IntegerRange>
{
new IntegerRange
{
Start = 1L,
End = 1L,
},
},
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,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Print.Printers["{printer-id}"].Jobs["{printJob-id}"].Redirect.PostAsync(requestBody);
mgc-beta print printers jobs redirect post --printer-id {printer-id} --print-job-id {printJob-id}
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphprint "github.com/microsoftgraph/msgraph-beta-sdk-go/print"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphprint.NewRedirectPostRequestBody()
destinationPrinterId := "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea"
requestBody.SetDestinationPrinterId(&destinationPrinterId)
configuration := graphmodels.NewPrintJobConfiguration()
feedOrientation := graphmodels.LONGEDGEFIRST_PRINTERFEEDORIENTATION
configuration.SetFeedOrientation(&feedOrientation)
integerRange := graphmodels.NewIntegerRange()
start := int64(1)
integerRange.SetStart(&start)
end := int64(1)
integerRange.SetEnd(&end)
pageRanges := []graphmodels.IntegerRangeable {
integerRange,
}
configuration.SetPageRanges(pageRanges)
quality := graphmodels.MEDIUM_PRINTQUALITY
configuration.SetQuality(&quality)
dpi := int32(600)
configuration.SetDpi(&dpi)
orientation := graphmodels.LANDSCAPE_PRINTORIENTATION
configuration.SetOrientation(&orientation)
copies := int32(1)
configuration.SetCopies(&copies)
duplexMode := graphmodels.ONESIDED_PRINTDUPLEXMODE
configuration.SetDuplexMode(&duplexMode)
colorMode := graphmodels.BLACKANDWHITE_PRINTCOLORMODE
configuration.SetColorMode(&colorMode)
inputBin := "by-pass-tray"
configuration.SetInputBin(&inputBin)
outputBin := "output-tray"
configuration.SetOutputBin(&outputBin)
mediaSize := "A4"
configuration.SetMediaSize(&mediaSize)
margin := graphmodels.NewPrintMargin()
top := int32(0)
margin.SetTop(&top)
bottom := int32(0)
margin.SetBottom(&bottom)
left := int32(0)
margin.SetLeft(&left)
right := int32(0)
margin.SetRight(&right)
configuration.SetMargin(margin)
mediaType := "stationery"
configuration.SetMediaType(&mediaType)
finishings := null
configuration.SetFinishings(&finishings)
pagesPerSheet := int32(1)
configuration.SetPagesPerSheet(&pagesPerSheet)
multipageLayout := graphmodels.CLOCKWISEFROMBOTTOMLEFT_PRINTMULTIPAGELAYOUT
configuration.SetMultipageLayout(&multipageLayout)
collate := false
configuration.SetCollate(&collate)
scaling := graphmodels.SHRINKTOFIT_PRINTSCALING
configuration.SetScaling(&scaling)
fitPdfToPage := false
configuration.SetFitPdfToPage(&fitPdfToPage)
requestBody.SetConfiguration(configuration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
redirect, err := graphClient.Print().Printers().ByPrinterId("printer-id").Jobs().ByPrintJobId("printJob-id").Redirect().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.print.printers.item.jobs.item.redirect.RedirectPostRequestBody redirectPostRequestBody = new com.microsoft.graph.beta.print.printers.item.jobs.item.redirect.RedirectPostRequestBody();
redirectPostRequestBody.setDestinationPrinterId("9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea");
PrintJobConfiguration configuration = new PrintJobConfiguration();
configuration.setFeedOrientation(PrinterFeedOrientation.LongEdgeFirst);
LinkedList<IntegerRange> pageRanges = new LinkedList<IntegerRange>();
IntegerRange integerRange = new IntegerRange();
integerRange.setStart(1L);
integerRange.setEnd(1L);
pageRanges.add(integerRange);
configuration.setPageRanges(pageRanges);
configuration.setQuality(PrintQuality.Medium);
configuration.setDpi(600);
configuration.setOrientation(PrintOrientation.Landscape);
configuration.setCopies(1);
configuration.setDuplexMode(PrintDuplexMode.OneSided);
configuration.setColorMode(PrintColorMode.BlackAndWhite);
configuration.setInputBin("by-pass-tray");
configuration.setOutputBin("output-tray");
configuration.setMediaSize("A4");
PrintMargin margin = new PrintMargin();
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(PrintMultipageLayout.ClockwiseFromBottomLeft);
configuration.setCollate(false);
configuration.setScaling(PrintScaling.ShrinkToFit);
configuration.setFitPdfToPage(false);
redirectPostRequestBody.setConfiguration(configuration);
var result = graphClient.print().printers().byPrinterId("{printer-id}").jobs().byPrintJobId("{printJob-id}").redirect().post(redirectPostRequestBody);
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/d5ef6ec4-07ca-4212-baf9-d45be126bfbb/jobs/44353/redirect')
.version('beta')
.post(printJob);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Print\Printers\Item\Jobs\Item\Redirect\RedirectPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PrintJobConfiguration;
use Microsoft\Graph\Beta\Generated\Models\PrinterFeedOrientation;
use Microsoft\Graph\Beta\Generated\Models\IntegerRange;
use Microsoft\Graph\Beta\Generated\Models\PrintQuality;
use Microsoft\Graph\Beta\Generated\Models\PrintOrientation;
use Microsoft\Graph\Beta\Generated\Models\PrintDuplexMode;
use Microsoft\Graph\Beta\Generated\Models\PrintColorMode;
use Microsoft\Graph\Beta\Generated\Models\PrintMargin;
use Microsoft\Graph\Beta\Generated\Models\PrintMultipageLayout;
use Microsoft\Graph\Beta\Generated\Models\PrintScaling;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new RedirectPostRequestBody();
$requestBody->setDestinationPrinterId('9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea');
$configuration = new PrintJobConfiguration();
$configuration->setFeedOrientation(new PrinterFeedOrientation('longEdgeFirst'));
$pageRangesIntegerRange1 = new IntegerRange();
$pageRangesIntegerRange1->setStart(1);
$pageRangesIntegerRange1->setEnd(1);
$pageRangesArray []= $pageRangesIntegerRange1;
$configuration->setPageRanges($pageRangesArray);
$configuration->setQuality(new PrintQuality('medium'));
$configuration->setDpi(600);
$configuration->setOrientation(new PrintOrientation('landscape'));
$configuration->setCopies(1);
$configuration->setDuplexMode(new PrintDuplexMode('oneSided'));
$configuration->setColorMode(new PrintColorMode('blackAndWhite'));
$configuration->setInputBin('by-pass-tray');
$configuration->setOutputBin('output-tray');
$configuration->setMediaSize('A4');
$configurationMargin = new PrintMargin();
$configurationMargin->setTop(0);
$configurationMargin->setBottom(0);
$configurationMargin->setLeft(0);
$configurationMargin->setRight(0);
$configuration->setMargin($configurationMargin);
$configuration->setMediaType('stationery');
$configuration->setFinishings(null);
$configuration->setPagesPerSheet(1);
$configuration->setMultipageLayout(new PrintMultipageLayout('clockwiseFromBottomLeft'));
$configuration->setCollate(false);
$configuration->setScaling(new PrintScaling('shrinkToFit'));
$configuration->setFitPdfToPage(false);
$requestBody->setConfiguration($configuration);
$result = $graphServiceClient->escapedPrint()->printers()->byPrinterId('printer-id')->jobs()->byPrintJobId('printJob-id')->redirect()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Devices.CloudPrint
$params = @{
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
}
}
Invoke-MgBetaRedirectPrintPrinterJob -PrinterId $printerId -PrintJobId $printJobId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.print.printers.item.jobs.item.redirect.redirect_post_request_body import RedirectPostRequestBody
from msgraph_beta.generated.models.print_job_configuration import PrintJobConfiguration
from msgraph_beta.generated.models.printer_feed_orientation import PrinterFeedOrientation
from msgraph_beta.generated.models.integer_range import IntegerRange
from msgraph_beta.generated.models.print_quality import PrintQuality
from msgraph_beta.generated.models.print_orientation import PrintOrientation
from msgraph_beta.generated.models.print_duplex_mode import PrintDuplexMode
from msgraph_beta.generated.models.print_color_mode import PrintColorMode
from msgraph_beta.generated.models.print_margin import PrintMargin
from msgraph_beta.generated.models.print_multipage_layout import PrintMultipageLayout
from msgraph_beta.generated.models.print_scaling import PrintScaling
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = RedirectPostRequestBody(
destination_printer_id = "9a3b3956-ce5b-4d06-a605-5b0bd3e9ddea",
configuration = PrintJobConfiguration(
feed_orientation = PrinterFeedOrientation.LongEdgeFirst,
page_ranges = [
IntegerRange(
start = 1,
end = 1,
),
],
quality = PrintQuality.Medium,
dpi = 600,
orientation = PrintOrientation.Landscape,
copies = 1,
duplex_mode = PrintDuplexMode.OneSided,
color_mode = PrintColorMode.BlackAndWhite,
input_bin = "by-pass-tray",
output_bin = "output-tray",
media_size = "A4",
margin = PrintMargin(
top = 0,
bottom = 0,
left = 0,
right = 0,
),
media_type = "stationery",
finishings = None,
pages_per_sheet = 1,
multipage_layout = PrintMultipageLayout.ClockwiseFromBottomLeft,
collate = False,
scaling = PrintScaling.ShrinkToFit,
fit_pdf_to_page = False,
),
)
result = await graph_client.print.printers.by_printer_id('printer-id').jobs.by_print_job_id('printJob-id').redirect.post(request_body)
响应
以下示例显示了相应的响应。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#printJob",
"@odata.type": "#microsoft.graph.printJob",
"id": "44354",
"displayName": "testjob",
"createdDateTime": "2020-06-30T17:19:09Z",
"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
}
}