C# implementation of Internet Printing Protocol/1.1 and some bits of CUPS 1.0.
It can print! And do other stuff with any printer, connected via Internet.
Available on [nuget][SharpCUPS.nuget]
var cupsUri = new Uri("https://cupsPrintServer");
var client = new SharpIppClient(cupsUri, httpClient);await using var stream = File.Open(@"c:\file.pdf", FileMode.Open);
var printerUri = new Uri("ipp://192.168.0.1:631");
var request = new PrintJobRequest
{
PrinterUri = printer,
Document = stream,
JobName = "Test Job",
IppAttributeFidelity = false,
DocumentName = "Document Name",
DocumentFormat = "application/octet-stream",
DocumentNaturalLanguage = "en",
MultipleDocumentHandling = MultipleDocumentHandling.SeparateDocumentsCollatedCopies,
Copies = 1,
Finishings = Finishings.None,
PageRanges = new[] {new Range(1, 1)},
Sides = Sides.OneSided,
NumberUp = 1,
OrientationRequested = Orientation.Portrait,
PrinterResolution = new Resolution(600, 600, ResolutionUnit.DotsPerInch),
PrintQuality = PrintQuality.Normal
};
var response = await client.PrintJobAsync(request);- Cancel-Job —
CancelJobAsync - Create-Job —
CreateJobAsync - Get-Job-Attributes —
GetJobAttributesAsync - Get-Jobs —
GetJobsAsync - Get-Job-Attributes —
GetPrinterAttributesAsync - Hold-Job —
HoldJobAsync - Pause-Printer —
PausePrinterAsync - Print-Job —
PrintJobAsync - Print-URI —
PrintUriAsync - Purge-Jobs —
PurgeJobsAsync - Release-Job —
ReleaseJobAsync - Restart-Job —
RestartJobAsync - Resume-Printer —
ResumePrinterAsync - Send-Document —
SendDocumentAsync - Send-URI —
SendUriAsync - Validate-Job —
ValidateJobAsync
- CUPS-Get-Printers —
GetCUPSPrintersAsync
Use method CustomOperationAsync to send fully customizable requests to your printer.
var request = new IppRequestMessage
{
RequestId = 1,
IppOperation = (IppOperation)0x000A,
Version = IppVersion.V11
};
request.OperationAttributes.AddRange(
new []
{
new IppAttribute(Tag.Charset, "attributes-charset", "utf-8"),
new IppAttribute(Tag.NaturalLanguage, "attributes-natural-language", "en"),
new IppAttribute(Tag.NameWithoutLanguage, "requesting-user-name", "test"),
new IppAttribute(Tag.Uri, "printer-uri", "ipp://localhost:631"),
new IppAttribute(Tag.Integer, "job-id", 1),
});
client.CustomOperationAsync("ipp://localhost:631", request);