Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (42 loc) · 1.45 KB
/
Copy pathProgram.cs
File metadata and controls
43 lines (42 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using SharpIpp;
using SharpIpp.Models.Requests;
using SharpIpp.Protocol.Models;
try
{
SharpIppClient client = new();
string filePath = @"C:\example.pdf";
await using var stream = File.Open(filePath, FileMode.Open);
PrintJobRequest printJobRequest = new()
{
Document = stream,
OperationAttributes = new()
{
PrinterUri = new Uri("ipp://localhost:631/"),
DocumentName = "Document Name",
DocumentFormat = DocumentFormat.ApplicationOctetStream,
Compression = Compression.None,
DocumentNaturalLanguage = new SharpIpp.Protocol.Models.NaturalLanguage("en"),
JobName = "Test Job",
IppAttributeFidelity = false
},
JobTemplateAttributes = new()
{
Copies = 1,
MultipleDocumentHandling = MultipleDocumentHandling.SeparateDocumentsCollatedCopies,
Finishings = new[] { Finishings.None },
PageRanges = new[] { new SharpIpp.Protocol.Models.Range(1, 1) },
Sides = Sides.OneSided,
NumberUp = 1,
OrientationRequested = Orientation.Portrait,
PrinterResolution = new Resolution(600, 600, ResolutionUnit.DotsPerInch),
PrintQuality = PrintQuality.Normal
}
};
var printJobresponse = await client.PrintJobAsync(printJobRequest);
Console.WriteLine("Success!");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.ReadKey();