Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can print PDF to BROTHER DCP-L2540DW but not to BROTHER HL-L2305 #15

Closed
squabtracker opened this issue Jul 4, 2023 · 3 comments
Closed
Labels
document-format not supported Printer doesn't support the document format the user is sending

Comments

@squabtracker
Copy link

I am printing via a Kotlin app using the below code.

HttpURLConnectionClient.log.logLevel = Logging.LogLevel.TRACE
val printer = IppPrinter(URI.create("ipp://$printerAddress/ipp/print"), httpConfig = Http.Config(debugLogging = true))
printer.attributes.logDetails()

// create job and send document
val job = printer.createJob(
                jobName(file.name),
                IppPrintQuality.Normal,
                IppColorMode.Monochrome,
)
job.sendDocument(FileInputStream(file))
job.logDetails()
job.waitForTermination()

The L2540DW prints just fine. I have tried adding in the port like ipp://$printerAddress:631/ipp/print and various other alternatives with and without /ipp/print and every time the L2540DW prints. But the HL-L2305 just starts kicking out blank page after blank page and never stops (I let it go to about 10 pages and then pulled the tray). I updated firmware on the printer but that didnt change anything. I verified the IPP is enabled via the printer web console but nothing seems to work. What else can I try?

@gmuth
Copy link
Owner

gmuth commented Jul 6, 2023

Successful physical printing depends on various things. It's very important to send data the printer understands. If you send a document in a pdl/format the printer does not support you get either errors or a behavior similar to what you described.

Your code assumes the printer just knows what you send. I recommend to set the documentFormat explicitly.

  • What is the file format?
  • What document formats does the printer support? check printer attribute "document-formats-supported".

@squabtracker
Copy link
Author

I am trying to print a pdf that was generated and saved prior to this print step. I have tried passing in application/pdf into the job but that didn't seem to make any difference on either printer.

// create job and send document
val job = printer.createJob(
                jobName(file.name),
                IppPrintQuality.Normal,
                IppColorMode.Monochrome,
                documentFormat("application/pdf"),
)

Running get-printer-attributes.test on both printers yields almost identical results. Both of them show:

document-format-supported (1setOf mimeMediaType) = application/octet-stream,image/urf,image/pwg-raster
document-format-default (mimeMediaType) = application/octet-stream

The rest of the output is almost identical between the two printers. Differences between them shown below.

Working

printer-device-id (textWithoutLanguage) = MFG:Brother;CMD:PJL,PCL,PCLXL,URF;MDL:DCP-L2540DW series;CLS:PRINTER;CID:Brother Laser Type1;URF:W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS300-600,V1.3,DM1;
urf-supported (1setOf keyword) = W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS300-600,V1.3,DM1

pwg-raster-document-resolution-supported (resolution) = 300dpi
pwg-raster-document-type-supported (keyword) = sgray_8

And non working

printer-device-id (textWithoutLanguage) = MFG:Brother;CMD:PJL,HBP,URF;MDL:HL-L2305 series;CLS:PRINTER;CID:Brother Laser Type1;URF:W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS300-600,V1.3;
urf-supported (1setOf keyword) = W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ4,RS300-600,V1.3

pwg-raster-document-resolution-supported (resolution) = 600dpi
pwg-raster-document-type-supported (1setOf keyword) = srgb_8,sgray_8

Should I be sending the document as something other than pdf?

@gmuth
Copy link
Owner

gmuth commented Jul 7, 2023

The printer does not announce support for PDF. As per spec the printer should reject printjobs with unsupported document formats. Unfortunately it's common practice for implementors to respond "Ok" even when requests are not ok.
Your printer only supports raster formats, so you need to transform/render pdf into a supported raster format.

Most (but not all) AirPrint printers support rendering a vector format like pdf or PCLm. However your printer is limited to URF (required by AirPrint) which is not publicly documented. pwg-raster should be a good candidate to look into.

@gmuth gmuth changed the title Can print to BROTHER DCP-L2540DW but not to BROTHER HL-L2305 Can print PDF to BROTHER DCP-L2540DW but not to BROTHER HL-L2305 Jul 7, 2023
@gmuth gmuth closed this as completed Jul 8, 2023
@gmuth gmuth added the document-format not supported Printer doesn't support the document format the user is sending label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document-format not supported Printer doesn't support the document format the user is sending
Projects
None yet
Development

No branches or pull requests

2 participants