Silent Printing with TideSDK
Asked Answered
C

2

8

UPDATE: I've decided to use appjs for my project, rather than TideSDK. With AppJS, you are able to easily make node modules, in which you can add C++ modules for easy use of silent printing. I'd recommend anyone interested in the topic to check it out. Best of luck to you all!

I'm developing an application with TideSDK - It's a really awesome framework, if you haven't tried it, set some time aside!

Anyway, I'm attempting to print using Javascript, but a Print Settings dialog comes up each time, as it would with other browsers. I'm trying to eliminate that box as well as pass along the printer I would like it to print with.

I'm aware that there are settings in FireFox for silent printing, that is was I used previously, but there aren't any similar options for TideSDK (That I have found).

After a ton of research, I think the only viable options consist of a python script, a C++ module or editing the TideSDK source and recompiling. All three sound like loosers to me. Modifying the TideSDK source and removing the dialog box from webkit_ui_delegate.cpp will most likely result in some issues when updating this program down the road - in addition to not being able to pass the printer name easily. The python script would require third party modules and would have to process the contents of the page, I doubt I would be able to write something that could do a quality job in that respect. Finally, I think the C++ solution is the most feasible since it has access to win32api, but again, it would have to process HTML to a print language, something i'm not familiar with. I guess i'm looking for more of a webkit solution that handles the rendering for me.

What should I do to implement silent printing on TideSDK? Please include code examples.

I'm looking for a windows solution primarily, I've already figured out the other platforms.

Thank you for your time and I appreciate the feedback!

Chinn answered 10/1, 2013 at 23:34 Comment(9)
Why do you think modifying the TideSDK source code would be a bad solution? So long as it works, you could probably ask to have your changes reimported into the TideSDK master branch as it sounds like a useful option.Serviceman
@Serviceman - How would you pass a printer parameter to the printFrame function in webkit_ui_delegate.cpp? That was one of the main components of the question.Chinn
It might be worth it to post a question here: developer.appcelerator.com/questions/newestNosy
@Nosy I think think they support TideSDK anymore, sadly.Chinn
Its appropriate in the circumstances to file a feature request, contribute to the solution or sponsor the work if it is meaningful to your project.Blob
@Blob There has been a open request for this on JIRA and GitHub for quite some time. I just wanted to see if the community had a good idea on implementing it. I really enjoy using TideSDK and I appreciate the amount of work that you and your fellow developers put into it.Chinn
@Chinn We've got about 20 feature requests together with other significant work we are prioritizing. We are still in beta and close to the next 1.3.2-beta release. The answer accepted is frustrating and discouraging and is not helpful to TideSDK users. Time and resources are a consideration for how quickly we move forward. While I understand what you want and desire with your question, the scope of the Q & A forum is limited. We would not code a solution in this forum.Blob
@Blob I completely understand. No disrespect to you or any other TideSDK developers, I just didn't want 500 rep to go to waste, and it is most likely going to be the route I will take.Chinn
I am interested doing something similar. How did you generate the print job ?Ligroin
C
0

Sad to see this question didn't get any quality answers, this is something I wanted to implement myself.

I think it would be quite a venture to invest the time required to get this feature working with TideSDK. Because of that, I'm going to stray away from the core competencies of the question and recommend that you try a framework other than TideSDK to accomplish this. I think that is the most realistic solution to this problem, and it will be the one that I take.

I'll update this answer once I find the framework I'll be sticking with.

Camper answered 19/1, 2013 at 23:18 Comment(6)
This is most likely going to be the route I will take. It's a pitty - it's quite a good framework. I'll just reward you the bounty so the points don't go to waste. Best of luck to you and your application.Chinn
Indeed. Thanks for the bounty, but I don't really think I deserve it. Best of luck to you as well.Camper
Heh, it was either you or no one could use them. Let me know what framework you go with.Chinn
I am not sure the assessment is fair. It is possible to implement but not trivial nor could the question be simply answered. Our code base is written in a way that we don't solve the issue with a single platform priority. I would suggest sponsoring the work to contribute to the solution as an alternative.Blob
The answer is unfair. It does not properly answer the question with what was requested. Please consider the size of the codebase and scope of TideSDK. We currently have a number of open feature requests. Your request would be considered and prioritized among these since our resources are limited. Rather than suggest another framework (which is rare in this space), you could contribute in a meaninful way to the solution. If you have the skills to code it or collaborate on it, please get in touch.Valval
@MitalVora I just want to be clear that neither I nor the respondent have anything against TideSDK. From his response, it looks like he thinks it is a great framework - as do I. This question was simply asking how to implement a feature and he answered with a realistic suggestion. I appreciate all the time that you and your fellow developers put into TideSDK, it's a great framework.Chinn
D
1

NOTE: this is a rewrite of an earlier question.

The way Windows/GDI+ printing works is that it uses a PrintDialog to obtain a printer identifier (and to also let the user know what printer they are printing to). So in order to have silent printing, you need to obtain a printer identifier without showing a dialog.

So REMOVE this code:

// Open a printing dialog to fetch the HDC of the desired printer.
PRINTDLG dialog;
ZeroMemory(&dialog, sizeof(PRINTDLG));
dialog.lStructSize = sizeof(PRINTDLG);
dialog.Flags = PD_PRINTSETUP | PD_RETURNDC;
BOOL dialogResult = ::PrintDlg(&dialog);

if (!dialogResult) // Error or cancel.
{
    DWORD reason = CommDlgExtendedError();
    if (!reason) // User cancelled.
        return S_OK;

    logger->Error("Could not print page, dialog error code: %i",
        reason);
    return E_FAIL;
}

HDC hdc = dialog.hDC;

And then replace the last line (HDC hdc = ...) with some other way of getting a printer HDC. You could use GetDefaultPrinter() to get the name of the default printer, and then get a HDC using CreateDC().

Optionally, you could select a printer or create a custom print dialog using the EnumPrinters() function.

Deviation answered 20/1, 2013 at 17:36 Comment(5)
OK, who downvoted me and why? What is wrong with this solution?Deviation
You can't execute C++ during runtime unless you develop a separate API - same thing I commented on your last answer.Chinn
@Deviation Thanks for the windows implementation for printing. You can contribute your C++ code in TideSDK. This is the proper solution that we would like to implement besides the same thing needs to be implemented for all the platforms.Valval
Thank you, I'll probably open a PR when I get time to. I will not be participating further in this question, the asker does not understand how Windows printing works or the fact that my code goes in webkit_ui_delegate.cpp and does not require another API.Deviation
@Deviation You can't pass parameters to that file, I don't think you understand. It isn't silent printing if they have to pick the printer, the code should be able to select.Chinn
C
0

Sad to see this question didn't get any quality answers, this is something I wanted to implement myself.

I think it would be quite a venture to invest the time required to get this feature working with TideSDK. Because of that, I'm going to stray away from the core competencies of the question and recommend that you try a framework other than TideSDK to accomplish this. I think that is the most realistic solution to this problem, and it will be the one that I take.

I'll update this answer once I find the framework I'll be sticking with.

Camper answered 19/1, 2013 at 23:18 Comment(6)
This is most likely going to be the route I will take. It's a pitty - it's quite a good framework. I'll just reward you the bounty so the points don't go to waste. Best of luck to you and your application.Chinn
Indeed. Thanks for the bounty, but I don't really think I deserve it. Best of luck to you as well.Camper
Heh, it was either you or no one could use them. Let me know what framework you go with.Chinn
I am not sure the assessment is fair. It is possible to implement but not trivial nor could the question be simply answered. Our code base is written in a way that we don't solve the issue with a single platform priority. I would suggest sponsoring the work to contribute to the solution as an alternative.Blob
The answer is unfair. It does not properly answer the question with what was requested. Please consider the size of the codebase and scope of TideSDK. We currently have a number of open feature requests. Your request would be considered and prioritized among these since our resources are limited. Rather than suggest another framework (which is rare in this space), you could contribute in a meaninful way to the solution. If you have the skills to code it or collaborate on it, please get in touch.Valval
@MitalVora I just want to be clear that neither I nor the respondent have anything against TideSDK. From his response, it looks like he thinks it is a great framework - as do I. This question was simply asking how to implement a feature and he answered with a realistic suggestion. I appreciate all the time that you and your fellow developers put into TideSDK, it's a great framework.Chinn

© 2022 - 2024 — McMap. All rights reserved.