Jump to content

Could I print a PDF file directly from JS ?


KingOrmon

Recommended Posts

Check this: code.google.com/p/jzebra/

I strongly advise againt it, java applets technology is dead. Noone is supporting it except Oracle, buy they don't have a word in modern web development, and sooner or later all browsers will stop working with applets. Don't trap yourself in dead technologies.

Link to comment
Share on other sites

I strongly advise againt it, java applets technology is dead. Noone is supporting it except Oracle, buy they don't have a word in modern web development, and sooner or later all browsers will stop working with applets. Don't trap yourself in dead technologies.

 

Thank you for your advise. It is a very good for our community, but this the solution I find to print out directly to printers in any browser and it works very well, not just for FF o Chrome, etc... it works in all of they. At the same time it is "transparent" to my application, so I will be able to change it when I will find a better solution. I suggest him, and it could be use now while there are not another solution, and later change it.

Link to comment
Share on other sites

I think applets have 2-3 more years before they'll be abandoned in browsers (until some miracle happens of course, like Oracle becoming the best friends with Google/Mozilla/Microsoft). But it is not the real problem. You must have java installed for this to work. Your users must install java. So if you have a several hundreds of users, all of them must install java.

I think that the web apps should work with a bare browser without any additional plugins. If you are forcing your customers to install additional components for you web app to work correctly, it would be better just to write a normal desktop app.

You force them to install something, so why not just force them to install a desktop application with a much larger capabilities than any web app can ever provide.

The true beauty of web applications is just that they work in browser, which is built-in in any OS.

Link to comment
Share on other sites

  • 2 months later...

procedure TUniForm5.UniButton5Click(Sender: TObject);

begin

//用fr生成PDF

frReport1.LoadFromFile(ExtractFileDir(ParamStr(0)) + '\pr.frf');

frReport1.PrepareReport;

pdffilename := RandomStr(true, true, true, 8);

frReport1.ExportTo(frllPDFExport1, UniServerModule.TempFolderURL +

pdffilename + '.pdf');

 

UniSession.AddJS(

'function bulkpdfPrint(srcFiles)'+

'{'+

' var pdf = document.getElementById("createPDF");'+

' if (pdf != undefined && pdf != null)'+

' {'+//判断pdf对象是否存在,如果存在就删除该对象

' var parentNode = pdf.parentNode;'+

' parentNode.removeChild(pdf);'+

' }'+

' var p = document.createElement("object");'+

' p.id = "createPDF";'+

' p.classid = "CLSID:CA8A9780-280D-11CF-A24D-444553540000";'+

' p.width = 1;'+

' p.height = 1;'+

' p.src = srcFiles;'+

' document.body.appendChild(p);'+

' p.printAll();'+

'};'+

'bulkpdfPrint("'+UniSession.URL+UniServerModule.TempFolderURL + pdffilename + '.pdf'+'");'//打印PDF

);

end;

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...