Qq, I'm Eugene! Senior Backend Developer and DevOps. Used to ba a funny tech youtuber. You can reach me in english or russian in
zelenov / sharpipp Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Qq, I'm Eugene! Senior Backend Developer and DevOps. Used to ba a funny tech youtuber. You can reach me in english or russian in
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.
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
HI,
how to set the jobname can show Chinese words?
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.
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
First, let me thank you for creating this library just when I needed it. Now for the issue:
According to section 5.3.6 of RFC 8011, job-originating-user-name
is of type name(MAX)
, which, according to section 5.1.3, can be either nameWithLanguage
or nameWithoutLanguage
. Currently, SharpIpp defines it as StringWithLanguage?
, which causes trouble when communicating with CUPS, which returns it as nameWithoutLanguage
.
It seems that order of populating AdditionalOperationAttributes and RequestedAttributes is reversed in this method as server is always rejecting it.
It should be first AdditionalOperationAttributes and then RequestedAttributes. When I changed it in my local copy of this library, it started to work.
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
How do I specify the media-source
(e.g. tray-3
) in the Job Attributes?
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;
}
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),
}
Hi, wonderful job with the library. I was wondering whether there are plan to support also protocol version 2.0 and above.
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!
When querying the information of a printer I get the following error: The printer or class does not exist (ClientErrorNotFound)
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
This should solve any issues addresed by #16 but won't break usages that currently supply an ipp uri scheme.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.