Jump to content

Print PDF direct to Printer - Help


herculanojs

Recommended Posts

Hello everyone
After reading all the post on printing unigui I met, none had any concrete solution. At least they solved the problem, not the answer posted.
So I have the following scenario to which necessecito help and solution:
 
Print the PDF report that is being shown in a frame directly to the printer without a preview before. Ie have situations where the report after created, must now be sent to the printer.
 
I greatly appreciate the help and attention
 
 
 
Ola a todos
Após ler todos os post sobre impressão com unigui que encontrei, nenhum apresentou alguma solução concreta. Pelo menos se solucionaram o problema, não postaram a resposta.
Sendo assim tenho o seguinte cenário aos quais necessecito de ajuda e solução:
 
Imprimir o relatório PDF que esta sendo mostrado em um frame diretamente para a impressora, sem que haja um preview antes. Ou seja, tenho situações em que o relatório após criado, já deve ser enviado para a impressora.
 
Agradeço imensamente a ajuda e atenção

 

Link to comment
Share on other sites

Hi,

If you want to send a pdf directly to the printer, then for this, there is no "complete solution",

and it depends on the client's browser settings, the type of browser, Safety settings, the type of network...

You can look for answers on the Internet,
For example here are some answers:

 

1. ... You are not going to be able to print silently with plain old JavaScript. How would you like your printer to start printing out 100000000 pages of all black. Not a good thing. If you want to print silently and have it work for Internet Explorer only, there are ActiveX controls out there that can do it. This requires higher security settings for your page and for your users to really trust your site.

http://stackoverflow.com/questions/975652/silent-print-a-embedded-pdf

 

2. ... It's not possible, and there are a few good reasons for that:
    the user could want to choose a printer himself
    the user could want to be able to control when his printer gets activated (imagine nasty auto-selfprinting advertisement popups...)
    the user could want to specify printer settings (grayscale or color, resolution, size, ...)

http://stackoverflow.com/questions/4292373/javascript-print-without-print-dialog-box

 

Best regards.

Link to comment
Share on other sites

To understand what you reported.

I am migrating an entire ERP for unigui, and I have some routines that must issue bar codes in direct communication with the device (printer), as well as other aplciação FastFood delivery, the vouchers should be immediately sent to the printer without preview.

 

Resolving these issues?

Link to comment
Share on other sites

Yes, in most cases it would not be desirable that a website could suppress the dialog box.

 

But in a few cases, such as this example where he's trying to print a receipt for his business from the browser. As I understand in such a case every second is too precious to be wasted confirming potentially hundreds of receipt per day.

 

It's a business after all, where time is money!

 

There are countless other cases where one would like to suppress the dialog box, such as the eBay sellers printing their labels before shipment.

 

So ideally the website developer should be able to specify some basic parameters such as printer name, color/monochromatic, quality, paper size. And command the print entirely from the source coude without requiring any action from the user, except of course to configure these parameter only once.

Link to comment
Share on other sites

I do not believe that no one has yet had the nessecidade of interfazear with some equipment on the client machine such as (POS, ECF, bar code printer, etc.).

I have practice in javascript or java. I opted for unigui the ease and knowledge already in Delphi.

greatly appreciate help in this direction.

It is what is taking today so you can complete this migration project.

Link to comment
Share on other sites

This (very old) solution is based on ActiveX, just like Delphi Developer explained in his first answer.

So yes, it is possible with uniGUI, but that is not a good idea: it will work only on Internet Explorer, and user must accept unsigned ActiveX contrôle and set his security settings to lowest values.

 

Otherwise, there is no way to print directly from a Web page without an explicit action of the user. That is not a limitation of uniGUI, that is the way Internet is.

Link to comment
Share on other sites

Hi 

It sounds as if your situation is a retail type scenario ? In this case if the client is at a known location it is likely the printer(s) required are always the same ones for a given client location. If this is the case it's possible to use a couple of solutions - for the first the printer will need to be accessible from the server by some means though - which may not be such a limitation in this scenario.

e.g.

Client at 'Terminal 1, Shop1' i.e. a know  location - Install the printer as being accessible from the server and then use lpr to send the job directly to it. winexec / ShellExecute    the minimal payload is simply  "lpr -Stheservername -Ptheportname thefilename"

 

or use a small piece of client software on the client running in the tray that handles printing to predefined printers.

e.g for windows clients a simple Webbroker wizard type app running in the tray can receive a request from the UniGui server to perform a number of actions on the client (such as show a pdf or depending on the locally installed PDF viewer print it without additional dialogs). For example SumatraPDF (which is free) has various direct printing options [ https://github.com/sumatrapdfreader/sumatrapdf/wiki/Command-line-arguments] as do some others.

 

Whilst the end result is pretty transparent to the user it does entail a bit of additional set up initially.
 
All the best
Link to comment
Share on other sites

I saw in action 2 solutions.

 

1. A system service that deals with printing. The web application writes in a special table what label should be printed and to what printer.

    The server has the printers defined and the printing service scans that table, generate the reports and sends the

    respective labels/reports to the appropriate printer.

2. If it's about barcode labels, there is a product called Bartender that somehow does the same thing but only(?) for Zebra

    labels (ZPL language). N.B. Bartender is not cheep !

 

Downside of this is that you either have to be on a LAN or on a VPN to do this.

 

I have heard of Java scripts inside the PDF but I haven't seen it done.

Link to comment
Share on other sites

Otherwise, you can take a look at this topic: http://stackoverflow.com/questions/945691/automatically-print-image-from-website

 

AttendStar created a free add-on that suppresses the dialog box and removes all headers and footers for most versions of Firefox.

https://addons.mozilla.org/en-US/firefox/addon/attendprint/

 

and

 

The only solution to avoid print dialog that I found was creating a variable on Mozilla Firefox to set auto-print. Maybe is not the best solution if you need to use other browser, but in my case, I only need to print a report automatically and it works:

1- Open Firefox and type "about:config" in the address bar
2- Right click on any preference and select "New" > "Boolean"
3- Add a variable called "print.always_print_silent" with "true" value
4- Restart Firefox.

Hope help you!

 

 

 

It will work only with Firefox, but I guess it is better than nothing for your business case.

Link to comment
Share on other sites

I thought it would be easier to use unigui than working with PHP or another language to migrate my system to the browser. I unfortunately came to the conclusion that I'm swimming to die on the beach.

This issue print I think it is important these days.

There is to be no simple way to do this in the framework.

PHP can smoothly perform this task.

How do not know javascript, I'm lost, and it is not possible that there is no way to do it.

 

Something as simple and looks like a show to run.

Link to comment
Share on other sites

Hi!

 

Is there any property in unigui indicating if I'm on the server?

 

I'm sorry, can you clarify ?!

 

 

 

PHP can smoothly perform this task.

 

Do you want print on the client side or the server side ?!

 

 

Thanks.

Link to comment
Share on other sites

There is to be no simple way to do this in the framework.

There is no simple way to achieve something that is not possible on a Web application.

 

PHP can smoothly perform this task.

No, it can't. There is no Web framework that can do this, because there is no Web browser that allows such a thing.
Link to comment
Share on other sites

We're developing a browser-based app that needs to print labels and invoices regularly.

We want to be able to print to the local printer without clicking through the the usual browser print dialogs.

Is this impossible?

We don't want to have to setup a whole CUPS printer network and deal with all that, the users having to click through a print dialog 1000 times a day isn't an option.

 

We have the need to print on the client.

 

It's not impossible.
Believe that the javascript experts must have a solution.
 

http://stackoverflow.com/questions/3056876/print-from-chrome-without-the-print-dialogs-using-greasemonkey-userscript-maybe

There are various ways to print a document without requiring user interaction. One way is to use the doc object’s print method and set the bSilent attribute to true, as shown in “Printing PDF Documents” on page 79 and in the following example: this.print({bUI: false, bSilent: true, bShrinkToFit: true});

 

In the first example below, pages 1-10 of the document are sent to the default printer, print silently without user interaction, and are shrunk to fit the imageable area of the pages:

 

this.print({ bUI: false, bSilent: true, bShrinkToFit: true, nStart: 1, nEnd: 10 });

Link to comment
Share on other sites

Your solution prints a document from Adobe Acrobat Reader, not from a Web page itself. So it requires 3 things :
- You must be able to produce a pdf document with embedded AcroJS code into your pdf (which is not standard Javascript, and not standard pdf document ; I guess that you must buy Adobe Acrobat to achieve such a thing)
- Your client must install Adobe Acrobat Reader and define it as default pdf viewer
- Your client must allow scripts to be executed from a pdf page by  defining properly Acrobat security settings


So this solution requires a third-party component (Adobe Acrobat Reader) just like other solutions previously proposed (ActiveX or Firefox plugin).
It doesn't allow to print silently without a plugin, there is no universal solution because it is just not possible.  Internet Browsers strictly forbid direct silent printing.
 

And you newest solution needs a Java plugin, which is another plugin (be aware that Java applet are not supported anymore by Chrome and Firefox) + you must place local libraries on machine of your Customers.

 

This matter has nothing to do with uniGUI: it is impossible to silently print from a web page without a plugin. 

Link to comment
Share on other sites

Then reaching completion.

With unigui will be impossible to print bar codes POS printers?

Applications developed in unigui which need to print tickets, payment slips, etc. in a way that does not require the user having to get by clicking on a button, etc. or be viewing the preview of the document, and having to click on something to print is impossible?

 

Applications for the purpose such as commercial automation, with unigui then be impossible?

 

This is the final conclusion?

Link to comment
Share on other sites

Someone tell if this works? And would any examples that you can share?

 

https://gist.github.com/bkrajendra/c80de17b627e59287f7c

 

Does anyone know say if this works? And would some exmplo that could share?
 
I am asking for help, because I understand that there are people here much more skilled with much higher knowledge than me. I'm just a beginner, still do not understand java script, but we are studying, then we can also contribute.
 
In the far already fomented a great discussion on the topic, which I think should be taken into consideration.
Link to comment
Share on other sites

It's not a unigui limitation it is a deliberate policy that Browsers should not be able to initiate printing silently.

 

If you know the printer you want to direct output to in advance (i.e predefined a method to get to it) then you can do it silently from the user's point of view, either from the Client's or the Server's perspective but you can't just roll up with any old browser and print to the client's default printer without a dialog.

Link to comment
Share on other sites

I got it, perfect.

I have at least one way for me to put a button on a preview form which will be showing the pdf in a UniURLFrame and at least already trigger the dialog box for printing?

This has help.

 

And while there is still some way to be able to move to the result of a function, return within a messagedlg?

 


Example:

 

function teste: boolean;

begin

         result: = false;

         MessageDlg ('My question?' MtConfirmation, mbYesNo,

             procedure (Sender: TComponent; Res: Integer)

             begin

               Res case of

                 mrYes:

                 begin

                           // Run code

 

                          is there any chance of returning to the function?

                 end;

               end;

             end

           );

end;

Link to comment
Share on other sites

Hi, this might be a solution to your problem, the think is common to all and had not planned for the migration of our system unigui
1. Supposed to print labels possibly we are in intranet , which means that we know the IP .
Imprimr labels to a file that identify Could we send the file name to a program that resides on client and traditionally prime

For this serious problem important support technicians UNIGUI

Link to comment
Share on other sites

Yes you are right logistcasoft

 

At first I am working with the following methodology in testing.
If the user is running on the server, use the same api Delphi and send the direct print to the printer or preview as appropriate.
On the server is quiet.
 
The problem arises when it is in season.
 
In this case I'm testing like this:
a) When direct printing preview, the printer installed on the client must be mapped on the server. In the system which I am setting the default mapping for printing that season, and then direct it to this mapping. In the event of failure, they are present the preview.
This only for situations with PDF.
 
B) I will work with the hypothesis of an application Lazarus platform that will listen to a spot on the station. And in this place save the instructions and the file for printing. I still have to see how direct save the station (download).
 
I tested by mapping a Argox printer for bar code and printing work both the server and the client through mapping.
I came across access permission issues "access denied", but skirted making "net use" to map a virtual port.
 
At first wire the solution found.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...