Fl_Printer errors - how can I interpret them?

28 views
Skip to first unread message

Philip Rose

unread,
Apr 21, 2020, 9:08:00 AM4/21/20
to fltk.general
Hi,

I have my own printer inherited from Fl_Printer to produce custom prints from my application (e.g labels and summary listings). If I get a non-zero response from start_job(), is there a way I can find out why? In this particular case it was when I was using a PDF-writer to produce a PDF file showing what the output looked like, and I eventually realised I had the previous attempt still open in Adobe reader.

Regards Phil.

Manolo

unread,
Apr 21, 2020, 11:43:58 AM4/21/20
to fltk.general
I'm afraid that is not possible. The FLTK API does not detail the reason why a start_job() call may have failed.
That's mostly because that would be very OS-specific.

I have tried under MSWindows 10 the test/device.exe app and had it print to
"Microsoft print to pdf" twice, keeping open in Microsoft Edge the first resulting pdf file before
running the second print job.
The second print job fails at the StartDoc() OS call which returns -1, a sign of failure.
But Microsoft's doc gives no way to get more detail about the cause of that failure:

So, at least in that case, there's no way I can see to get more information than
"the print job failed to start".

Phil

unread,
Apr 21, 2020, 1:24:52 PM4/21/20
to fltkg...@googlegroups.com
Thanks Manolo, now I've been there it'll be the first thing I check.

Phil.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/80232d73-d087-43a4-a89f-4a05b522933f%40googlegroups.com.

gga

unread,
Apr 21, 2020, 1:30:11 PM4/21/20
to fltkg...@googlegroups.com

On 21/4/20 12:43, Manolo wrote:
> I'm afraid that is not possible. The FLTK API does not detail the
> reason why a start_job() call may have failed.
> That's mostly because that would be very OS-specific.
True.
> So, at least in that case, there's no way I can see to get more
> information than
> "the print job failed to start".

Under Windows, it might be possible to get the more info about the error
with the GetLastError() function.

https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code

> --

Gonzalo Garramuño

Greg Ercolano

unread,
Apr 21, 2020, 1:38:47 PM4/21/20
to fltkg...@googlegroups.com
On 2020-04-21 10:24, 'Phil' via fltk.general wrote:
> Thanks Manolo, now I've been there it'll be the first thing I check.

I suppose in your app you can pop a dialog warning of the various
possible causes of errors you notice that can be the problem,
and to have the user check the printer log on that platform,
as I imagine errors from the print system end up in a log somewhere,
e.g. on linux the /var/log/cups, on windows I don't know the Event Viewer?

Depending on how verbose you want to get, you can either recommend or
automatically open the printer error log. I think on windows you can
open the event viewer with e.g. system("eventvwr"); or some such.

Phil

unread,
Apr 21, 2020, 2:39:25 PM4/21/20
to fltkg...@googlegroups.com
Thanks Gonzalo, I'll give that a try.

Phil.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.

Manolo

unread,
Apr 22, 2020, 10:11:06 AM4/22/20
to fltk.general
I've committed to FLTK 1.4 an optional extra argument to Fl_Printer::begin_job()
the caller can use to receive a string describing the error, in case of error.
See test/device.cxx for an example of usage.

Philip Rose

unread,
Apr 23, 2020, 9:15:12 AM4/23/20
to fltkg...@googlegroups.com

Thanks Manolo,

 

I tested this in my application and looks good. I did notice that there Is no message if I cancel the print dialog, but it has a non-zero response from begin_job().

 

Phil.

 

Sent from Mail for Windows 10

--

You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.

Manolo

unread,
Apr 23, 2020, 10:24:17 AM4/23/20
to fltk.general


On Thursday, 23 April 2020 15:15:12 UTC+2, Philip Rose wrote:

Thanks Manolo,

 

I tested this in my application and looks good.

Good.

I did notice that there Is no message if I cancel the print dialog, but it has a non-zero response from begin_job().

Please, read completely the description of the begin_job() function, particularly its returned values.

 

Phil.

Phil

unread,
Apr 23, 2020, 2:13:48 PM4/23/20
to fltkg...@googlegroups.com
I only saw Nonzero was an error, in the latest fltk.pdf I had, and there wasn't such file in the fltk-master I downloaded today.

Phil.

 

Phil.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.

Manolo

unread,
Apr 23, 2020, 3:01:57 PM4/23/20
to fltk.general


On Thursday, 23 April 2020 20:13:48 UTC+2, Phil wrote:


On 23 Apr 2020 15:24, Manolo <manol...@gmail.com> wrote:


On Thursday, 23 April 2020 15:15:12 UTC+2, Philip Rose wrote:

Thanks Manolo,

 

I tested this in my application and looks good.

Good.

I did notice that there Is no message if I cancel the print dialog, but it has a non-zero response from begin_job().

Please, read completely the description of the begin_job() function, particularly its returned values.
I only saw Nonzero was an error, in the latest fltk.pdf I had, and there wasn't such file in the fltk-master I downloaded today.

Phil.

I see. The recent changes in the source code are not yet visible in the on-line doc, unfortunately.
One way out is to generate yourself the doc using Doxygen.
That is the doc of the Fl_Printer::begin_job() member function:

Phil

unread,
Apr 23, 2020, 3:36:08 PM4/23/20
to fltkg...@googlegroups.com
Thanks Manolo, but I looked at installing doxygen on a Windows machine and it looked far too daunting. Also migrating to a Linux environment was also daunting. I don't want to irrevocably convert my laptop or desktop to Linux. I have a raspberry pi 3, but not sure it will be up to what I want.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.

Ian MacArthur

unread,
Apr 23, 2020, 5:17:04 PM4/23/20
to fltkg...@googlegroups.com


> On 23 Apr 2020, at 20:36, 'Phil' wrote:
>
> Thanks Manolo, but I looked at installing doxygen on a Windows machine and it looked far too daunting.


Nah, they provide a binary installer these days:

http://doxygen.nl/files/doxygen-1.8.18-setup.exe

Which pretty much Just Works everywhere I’ve tried it...



> Also migrating to a Linux environment was also daunting. I don't want to irrevocably convert my laptop or desktop to Linux. I have a raspberry pi 3, but not sure it will be up to what I want.


I use Pi’s a lot: OK, so they aren’t exactly high-end (though the 4GB RAM Pi4 is surprisingly capable...) but they are powerful compared to the embedded devices I’m used to.

Certainly enough to build and test fltk on, and happily runs doxygen, cmake, yada, yada...

TBH my Pi3 builds fltk faster than some of my old Win7 boxes - though to be fair the Win7 boxes are seriously handicapped by the (employer's) deployment of McAfee that slows everything down to a crawl...



Albrecht Schlosser

unread,
Apr 23, 2020, 5:44:05 PM4/23/20
to fltkg...@googlegroups.com
On 4/23/20 9:01 PM Manolo wrote:
>
> On Thursday, 23 April 2020 20:13:48 UTC+2, Phil wrote:
>
> I only saw Nonzero was an error, in the latest fltk.pdf I had, and
> there wasn't such file in the fltk-master I downloaded today.
>
> I see. The recent changes in the source code are not yet visible in the
> on-line doc, unfortunately.

I recently updated our online documentation page which now shows for the
development docs:
https://www.fltk.org/documentation.php

--- citation ---

FLTK 1.4.x (Current Development)

Updated Apr 20, 2020; Git commit 811033af

Pre-release development documentation snapshot.

HTML (online)
PDF (1443 pages, 5300 KiB)
HTML (online, GitLab mirror, updated daily) <<<---

--- end of citation ---

The last line is a link to:
https://fltk.gitlab.io/fltk/

which should always be pretty much current.

BTW: I'll update the online (1.4) docs from time to time manually with
appropriate notes (update date and commit), but I recommend the GitLab
mirror for always up-to-date docs.

Manolo

unread,
Apr 24, 2020, 1:55:58 AM4/24/20
to fltk.general
Great! We have now daily updated on-line HTML doc for FLTK 1.4.
For member function Fl_Printer::begin_job(), that's at:
which shows it's possible to distinguish between
* the printing job began smoothly: the function returned 0
* the user cancelled the print request: the function returned 1
* there was an error attempting to begin the print job: the function returned ≥ 2

Philip Rose

unread,
Apr 24, 2020, 7:50:50 AM4/24/20
to fltkg...@googlegroups.com

Thanks Manolo,

 

I’ve book-marked the front page of that now for my reference.

 

Phil.

 

Sent from Mail for Windows 10

 

--

You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages