Jump to content

Print PDF file:How to print a pdf file directly?


55143681

Recommended Posts

6 hours ago, 55143681 said:

I use fastreport to design my report,
then save to pdf files.

I need to pring the pdf file,

First,I preview the pdf file,

Second,I press the pring button.

Can I print the pdf file directly without open it in browser first?

 

hello,

look here : https://www.google.com/search?q=javascript+print+directly+to+default+printer&oq=javascript+print+direct&aqs=chrome.2.69i57j0i19l4j0i19i22i30l5.10143j0j7&sourceid=chrome&ie=UTF-8

for many examples in javascript.

 

or look here:

 

 

 

Link to comment
Share on other sites

1 minute ago, irigsoft said:

You can create a Windows based service (with uniGui) and install it on a client machine.

Then, when the application from the browser wants to print directly, send data such as Base64 string to this service and use it to print.

How to do that?

Thanks.

Link to comment
Share on other sites

22 minutes ago, 55143681 said:

How to do that?

Thanks.

1. Create uniGui Application as Service (or StandAlone application if You want to show some data in a windows tray)

2. On this application You get sended data and then send it to the default printer. 

uniMainModule:

function mmReadDocument (iType: Integer; sDocument: String): String;
var
ParamsList,
sAnswerList,
sDataList     : TStringList;

Wait          : Integer;
I             : Integer;
begin
Wait := 0;
repeat
  sleep (5);
  Inc (Wait);

  If (Wait >= 36000) then break;
until (not ServerModule.isBusy);


TRY
sAnswerList := TStringList.Create;
sAnswerList.StrictDelimiter := True;

ParamsList := TStringList.Create;

sDataList := TStringList.Create;
sDataList.StrictDelimiter := True;
sDataList.Delimiter := '#';

sAnswerList.Text := '';

sDataList.DelimitedText := DecodeBase64 (sDocument);

ServerModule.isBusy := True;

TRY

  SEND DATA TO The default PRINTER

  ServerModule.isBusy := False;

  sAnswerList.Clear;
  ParamsList.Clear;
  sDataList.Clear;
EXCEPT
     on E:Exception do begin
        sAnswerList.Text := e.Message;
        ShowMessage ('2 ExecuteCommands Error:' + e.Message);
     end;
END;

end;

 

uniServerModule:

procedure TUniServerModule.UniGUIServerModuleHTTPCommand

begin

//check if pdf file is sended
if (POS ('/pdf',ARequestInfo.URI) > 0)
then begin
      // DO YOUR REST STUFF
      AResponseInfo.ResponseNo := 200;
      AResponseInfo.ContentEncoding := '1251';
      ARequestInfo.Document := mmReadDocument (2,Copy (ARequestInfo.Document,Length ('/pdf=')+1,Length (ARequestInfo.Document)));
      AResponseInfo.ContentText := ARequestInfo.Document;
      AResponseInfo.WriteContent;
      Handled := True;
      AResponseInfo.CloseSession;
end;

end;

 

3. from Server Application just send data.

      
 

Link to comment
Share on other sites

On 12/28/2021 at 8:26 PM, 55143681 said:

I use fastreport to design my report,
then save to pdf files.

I need to pring the pdf file,

First,I preview the pdf file,

Second,I press the pring button.

Can I print the pdf file directly without open it in browser first?

 

Try QZ Tray !!!

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...