„printJob“ erstellen
Artikel 01/31/2024
7 Mitwirkende
Feedback
In diesem Artikel
Namespace: microsoft.graph
Erstellen Sie einen neuen printJob für einen Drucker .
Erstellt außerdem ein neues printDocument , das dem printJob zugeordnet ist.
Hinweis: Ein Benutzer kann bis zu ca. 10.000 Druckaufträge in 10 Tagen übermitteln.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
Globaler Dienst
US Government L4
US Government L5 (DOD)
China, betrieben von 21Vianet
✅
✅
✅
❌
Berechtigungen
Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist . Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen . Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz .
Berechtigungstyp
Berechtigungen mit den geringsten Berechtigungen
Berechtigungen mit höheren Berechtigungen
Delegiert (Geschäfts-, Schul- oder Unikonto)
PrintJob.Create
PrintJob.ReadWrite, PrintJob.ReadWrite.All, PrintJob.ReadWriteBasic, PrintJob.ReadWriteBasic.All
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Nicht unterstützt
Anwendung
Nicht unterstützt
Nicht unterstützt
HTTP-Anforderung
POST /print/printers/{printerId}/jobs
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines printJob-Objekts an. Das printJob-Objekt sollte nur eine Konfigurationseigenschaft enthalten. Alle Eigenschaften der Konfiguration können NULL-Werte zulassen. Alle anderen Felder, einschließlich Auftrags- und Dokument-IDs, werden während der Ressourcenerstellung automatisch festgelegt und sollten nicht in der Anforderung bereitgestellt werden.
Derzeit unterstützt Universal Print nur ein printDocument pro printJob-Objekt .
Antwort
Bei erfolgreicher Ausführung gibt die Methode einen 201 Created
Antwortcode und ein printJob-Objekt und das zugeordnete printDocument-Objekt im Antworttext zurück.
Beispiele
Anforderung
POST https://graph.microsoft.com/v1.0/print/printers/{printerId}/jobs
Content-Type: application/json
{
"configuration": {
"@odata.type": "microsoft.graph.printJobConfiguration",
"feedOrientation": "longEdgeFirst",
"pageRanges": [
{
"@odata.type": "microsoft.graph.integerRange",
"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.Models;
var requestBody = new PrintJob
{
Configuration = new PrintJobConfiguration
{
OdataType = "microsoft.graph.printJobConfiguration",
FeedOrientation = PrinterFeedOrientation.LongEdgeFirst,
PageRanges = new List<IntegerRange>
{
new IntegerRange
{
OdataType = "microsoft.graph.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.PostAsync(requestBody);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
mgc print printers jobs create --printer-id {printer-id} --body '{\
"configuration": {\
"@odata.type": "microsoft.graph.printJobConfiguration",\
"feedOrientation": "longEdgeFirst",\
"pageRanges": [\
{\
"@odata.type": "microsoft.graph.integerRange",\
"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\
}\
}\
'
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewPrintJob()
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
jobs, err := graphClient.Print().Printers().ByPrinterId("printer-id").Jobs().Post(context.Background(), requestBody, nil)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
PrintJob printJob = new PrintJob();
PrintJobConfiguration configuration = new PrintJobConfiguration();
configuration.setOdataType("microsoft.graph.printJobConfiguration");
configuration.setFeedOrientation(PrinterFeedOrientation.LongEdgeFirst);
LinkedList<IntegerRange> pageRanges = new LinkedList<IntegerRange>();
IntegerRange integerRange = new IntegerRange();
integerRange.setOdataType("microsoft.graph.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);
printJob.setConfiguration(configuration);
PrintJob result = graphClient.print().printers().byPrinterId("{printer-id}").jobs().post(printJob);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const printJob = {
configuration: {
'@odata.type': 'microsoft.graph.printJobConfiguration',
feedOrientation: 'longEdgeFirst',
pageRanges: [
{
'@odata.type': 'microsoft.graph.integerRange',
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')
.post(printJob);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\PrintJob;
use Microsoft\Graph\Generated\Models\PrintJobConfiguration;
use Microsoft\Graph\Generated\Models\PrinterFeedOrientation;
use Microsoft\Graph\Generated\Models\IntegerRange;
use Microsoft\Graph\Generated\Models\PrintQuality;
use Microsoft\Graph\Generated\Models\PrintOrientation;
use Microsoft\Graph\Generated\Models\PrintDuplexMode;
use Microsoft\Graph\Generated\Models\PrintColorMode;
use Microsoft\Graph\Generated\Models\PrintMargin;
use Microsoft\Graph\Generated\Models\PrintMultipageLayout;
use Microsoft\Graph\Generated\Models\PrintScaling;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new PrintJob();
$configuration = new PrintJobConfiguration();
$configuration->setOdataType('microsoft.graph.printJobConfiguration');
$configuration->setFeedOrientation(new PrinterFeedOrientation('longEdgeFirst'));
$pageRangesIntegerRange1 = new IntegerRange();
$pageRangesIntegerRange1->setOdataType('microsoft.graph.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()->post($requestBody)->wait();
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
Import-Module Microsoft.Graph.Devices.CloudPrint
$params = @{
configuration = @{
"@odata.type" = "microsoft.graph.printJobConfiguration"
feedOrientation = "longEdgeFirst"
pageRanges = @(
@{
"@odata.type" = "microsoft.graph.integerRange"
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
}
}
New-MgPrintPrinterJob -PrinterId $printerId -BodyParameter $params
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
from msgraph import GraphServiceClient
from msgraph.generated.models.print_job import PrintJob
from msgraph.generated.models.print_job_configuration import PrintJobConfiguration
from msgraph.generated.models.printer_feed_orientation import PrinterFeedOrientation
from msgraph.generated.models.integer_range import IntegerRange
from msgraph.generated.models.print_quality import PrintQuality
from msgraph.generated.models.print_orientation import PrintOrientation
from msgraph.generated.models.print_duplex_mode import PrintDuplexMode
from msgraph.generated.models.print_color_mode import PrintColorMode
from msgraph.generated.models.print_margin import PrintMargin
from msgraph.generated.models.print_multipage_layout import PrintMultipageLayout
from msgraph.generated.models.print_scaling import PrintScaling
graph_client = GraphServiceClient(credentials, scopes)
request_body = PrintJob(
configuration = PrintJobConfiguration(
odata_type = "microsoft.graph.printJobConfiguration",
feed_orientation = PrinterFeedOrientation.LongEdgeFirst,
page_ranges = [
IntegerRange(
odata_type = "microsoft.graph.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.post(request_body)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen , finden Sie in der SDK-Dokumentation .
Antwort
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#print/printJobs/$entity",
"id": "1825",
"createdDateTime": "2020-10-14T05:16:49-07:00",
"isFetchable": false,
"redirectedFrom": null,
"redirectedTo": null,
"createdBy": {
"id": "{userId}",
"displayName": "{username}",
"ipAddress": null,
"userPrincipalName": "{userupn}"
},
"status": {
"state": "paused",
"description": "The job is not a candidate for processing yet.",
"isAcquiredByPrinter": false,
"details": [
"uploadPending"
]
},
"configuration": {
"quality": "medium",
"dpi": 600,
"feedOrientation": "longEdgeFirst",
"orientation": "landscape",
"duplexMode": "oneSided",
"copies": 1,
"colorMode": "blackAndWhite",
"inputBin": "by-pass-tray",
"outputBin": "output-tray",
"mediaSize": "A4",
"mediaType": "stationery",
"finishings": null,
"pagesPerSheet": 1,
"multipageLayout": "clockwiseFromBottomLeft",
"collate": false,
"scaling": "shrinkToFit",
"fitPdfToPage": false,
"pageRanges": [
{
"start": 1,
"end": 1
}
],
"margin": {
"top": 0,
"bottom": 0,
"left": 0,
"right": 0
}
},
"documents": [
{
"id": "1477576d-5dab-4ea9-865c-c0b82cd70bd5",
"displayName": "",
"contentType": "",
"size": 0
}
]
}