Skip to content

Zelenov/SharpIpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
evzelenov
May 14, 2022
0d5450c · May 14, 2022

History

29 Commits
May 14, 2022
May 14, 2022
May 14, 2022
May 14, 2022
Apr 21, 2021
May 14, 2022
Apr 21, 2021
May 14, 2022
Apr 21, 2021
Apr 21, 2021

Repository files navigation

SharpIpp

SharpIpp Icon
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.

Installation

Available on nuget

PM> Install-Package SharpIpp

It prints

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);

Supported operations

IPP 1.1

CUPS 1.0

Custom operations

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);