Giter Site home page Giter Site logo

sharpipp's Introduction

sharpipp's People

Contributors

blackheart-tf avatar rcichielo avatar zelenov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sharpipp's Issues

Color printing attribute is ignored

I want to print page in black & white on a color printer. I do:

// this is to ensure that the printer supports the color parameter (and it does)
// request.ColorMode = "monochrome"
GetPrinterAttributesRequest attributesRequest = new GetPrinterAttributesRequest { PrinterUri = printerUri };
var attributesResponse = await client.GetPrinterAttributesAsync(attributesRequest);
var printColorModeAttribute = attributesResponse.Sections.FirstOrDefault(s => s.Tag == SectionTag.PrinterAttributesTag)
               ?.Attributes.Where(a => a.Name == "print-color-mode-supported")
               .Select(a => a.Value.ToString())
               .ToArray() ?? new string?[0];
var outputeModeAttribute = attributesResponse.Sections.FirstOrDefault(s => s.Tag == SectionTag.PrinterAttributesTag)
               ?.Attributes.Where(a => a.Name == "output-mode-supported")
               .Select(a => a.Value.ToString())
               .ToArray() ?? new string?[0];

if (printColorModeAttribute.Contains(request.ColorMode))
{
    colorPrintAttribues = new IppAttribute[]
    {
        new IppAttribute(Tag.Keyword, "print-color-mode", request.ColorMode)
    };
}
else if(outputeModeAttribute.Contains(request.ColorMode))
{
    colorPrintAttribues = new IppAttribute[]
    {
        new IppAttribute(Tag.Keyword, "output-mode", request.ColorMode)
    };
}
// ...
PrintJobRequest printRequest = new PrintJobRequest
{
    PrinterUri = printerUri,
    Document = documentStream,
    RequestingUserName = username,
    DocumentAttributes = new()
    {
        DocumentName = request.Document.FileName,
        DocumentNaturalLanguage = "en",
        DocumentFormat = mimeType
    },
    NewJobAttributes = new()
    {
        JobName = jobName,
        Copies = int.Max(1, int.Min(10, request.Copies)),
        Sides = sides,
        Media = "iso_a4_210x297mm"
    },
    AdditionalJobAttributes = colorPrintAttribues
};
await client.PrintJobAsync(printRequest);

But the CUPS pagelog shows the print-color-mode parameter to be empty ("-") and the document is always printed in color. The printer I test it on supports IPP Everywhere and it works fine from Mac or other library I use. Other parameters are passed fine.

ServerErrorVersionNotSupported

I am getting the following error with the Ipp server url http://{IpAddress}/printers/Xerox-WorkCentre-6505/.printer

Message: 
SharpIpp.Exceptions.IppResponseException : Printer returned error code
Version: 256
StatusCode: ServerErrorVersionNotSupported
RequestId: 1
Sections:
Tag: OperationAttributesTag

Attributes:
(Charset) attributes-charset: utf-8
(NaturalLanguage) attributes-natural-language: en-us
(TextWithoutLanguage) status-message: Server: (503) Version Not Supported

Having trouble printing a simple document:

Doc sends to the printer, but it just refuses to print, this is my PrintJobAsync result:

 {
  "Version": 257,
  "StatusCode": 0,
  "RequestId": 1,
  "JobUri": "ipp://10.10.0.229:631//job-15",
  "JobId": 15,
  "JobState": 5,
  "JobStateReasons": [
    "job-incoming"
  ],
  "JobStateMessage": null,
  "NumberOfInterveningJobs": null,
  "Sections": [
    {
      "Tag": 1,
      "Attributes": [
        {
          "Tag": 71,
          "Name": "attributes-charset",
          "Value": "utf-8"
        },
        {
          "Tag": 72,
          "Name": "attributes-natural-language",
          "Value": "en"
        }
      ]
    },
    {
      "Tag": 2,
      "Attributes": [
        {
          "Tag": 69,
          "Name": "job-uri",
          "Value": "ipp://10.10.0.229:631//job-15"
        },
        {
          "Tag": 33,
          "Name": "job-id",
          "Value": 15
        },
        {
          "Tag": 35,
          "Name": "job-state",
          "Value": 5
        },
        {
          "Tag": 68,
          "Name": "job-state-reasons",
          "Value": "job-incoming"
        }
      ]
    }
  ]
}

If I try sending a second document it throws this:

SharpIpp.Exceptions.IppResponseException: Printer returned error code
Version: V11
StatusCode: ServerErrorBusy
RequestId: 1
Sections:
Tag: OperationAttributesTag

So I have do a GetJobsAsync, then CancelJobAsync, then it allows me to try again. Any ideas why it gets stuck like that? Its just a tiny simple pdf file. Printer is a Brother TD-4420DN label printer.

Can´t print in JEPG Image

I need your help,

I am trying to test and print in JPEG which is a format supported by the IPP printer.

I get the array of bytes, which I add to a Stream to add to the Document property on the PrintJobRequest.

I command to print and it does not show an error but it does not print anything, with the PWG format I have no problem.

Maybe I'm omitting something, I leave evidence image.

Thank you

image

How to do Authentication with Sharpipp PrintJobRequest

Hi Team,

we are trying to send print job request to the IPP printer hosted in IIS wit basic authentication.
So we are expected to send a Authorization header with the print request.

Could you please guide us how we can do this ?

Thanks,
Joby

Doesn't print

Hi Evgeny,
I found SharpIpp on Nuget and it's what I need - send PDF file to a printer using IP. I tried to use it (got rid of async stuff though). It returns no error but the document is not printed. Not sure how to troubleshoot it as it's using client.PrintJobAsync(request) which returns OK. I'd appreciate any help.
Thank you,
Yuri

public static bool PrintPDFIPP(string printerIP,
string filename,
string paperName = null,
int copies = 1,
bool? isColor = null,
Duplex duplex = Duplex.Default)
{
var stream = File.Open(@filename, FileMode.Open);
var printerUri = new Uri(@"ipp://" + printerIP + ":631");
var request = new PrintJobRequest
{
PrinterUri = printerUri,
Document = stream,
JobName = Path.GetFileName(filename),
IppAttributeFidelity = false,
DocumentName = Path.GetFileName(filename),
DocumentFormat = "application /octet-stream",
DocumentNaturalLanguage = "en",
MultipleDocumentHandling = MultipleDocumentHandling.SeparateDocumentsCollatedCopies,
Copies = copies,
Finishings = Finishings.None,
//PageRanges = new[] { new Range(1, 1) },
Sides = (Sides)duplex,
//NumberUp = 1,
//OrientationRequested = Orientation.Portrait,
//PrinterResolution = new Resolution(600, 600, ResolutionUnit.DotsPerInch),
//PrintQuality = PrintQuality.Normal
};
SharpIppClient client = new SharpIppClient();
var response = client.PrintJobAsync(request);
return true;
}

Multiple finishings

public Finishings? Finishings { get; set; }
- this property doesn't allow using more than one finishing process in the job. Maybe it will be good to use something like this

public IEnumerable? Finishings { get; set; }

Am i getting it right that this workaround can do the same?

  AdditionalJobAttributes = new List<IppAttribute>()
  {
        new IppAttribute(Tag.Enum, "finishings", (int)Finishings.Punch),
        new IppAttribute(Tag.Enum, "finishings", (int)Finishings.Staple),
        new IppAttribute(Tag.Enum, "finishings", (int)Finishings.EdgeStitch),
  }

IPP version 2.x

Hi, wonderful job with the library. I was wondering whether there are plan to support also protocol version 2.0 and above.

GetJobAttributes Exception

Hello! Thanks for creating this library; it's the only one I could find to use ipp in .NET without gross amounts of boilerplate. I've been experimenting with it for use in a larger project and encountered the following exception:
No mapping found for types System.String -> System.Nullable[SharpIpp.Model.PrintQuality].
Here is the minimal reproduction:

var client = new SharpIppClient();
var uri = new Uri("ipp://<endpoint>:631");
var request = new GetJobAttributesRequest
{
	PrinterUri = uri,
	JobId = 1 // replace with extant ID
};
var response = await client.GetJobAttributesAsync(request);

If you could look into this at your convenience, I would greatly appreciate it!

ClientErrorNotFound

When querying the information of a printer I get the following error: The printer or class does not exist (ClientErrorNotFound)

uri scheme support

The http request scheme is currently hard coded, so using https or ipps is not currently supported.
ipp requests do not currently default to port 631.

If ipp or ipps is the scheme and a port is not provided, the port should default to 663 (and not 80/443).

This would be a breaking change for usages where

  • the uri scheme is ipp, but a port is not provided and a connection on port 80 is desired
  • ipps/https are specified but an insecure connection on port 80(when port is unspecified) is desired

This should solve any issues addresed by #16 but won't break usages that currently supply an ipp uri scheme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.