jrp Posted September 6, 2022 Share Posted September 6, 2022 Hello, In my application, when the user click "Show Report" then the application prepare a HTML file and display it in a new tab. How to convert it to a PDF file so the user can download it? Thanks Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted September 7, 2022 Share Posted September 7, 2022 We have used this in a number of places not just UniGui https://wkhtmltopdf.org/ 2 Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 7, 2022 Share Posted September 7, 2022 8 hours ago, jrp said: Hello, In my application, when the user click "Show Report" then the application prepare a HTML file and display it in a new tab. How to convert it to a PDF file so the user can download it? Thanks try with this: https://qawithexperts.com/article/javascript/easy-way-to-convert-html-to-pdf-using-javascript/335 or https://stackoverflow.com/questions/18191893/generate-pdf-from-html-in-div-using-javascript 1 Quote Link to comment Share on other sites More sharing options...
jrp Posted September 7, 2022 Author Share Posted September 7, 2022 Thank you Harry Rogers and irigsoft, I will try. Quote Link to comment Share on other sites More sharing options...
jrp Posted September 7, 2022 Author Share Posted September 7, 2022 5 hours ago, Harry Rogers said: We have used this in a number of places not just UniGui https://wkhtmltopdf.org/ Hello Harry Rogers, Could you share how you implemented calling wkhtmltopdf.exe from UniGUI app? Thanks Quote Link to comment Share on other sites More sharing options...
Harry Rogers Posted September 7, 2022 Share Posted September 7, 2022 All our work is done server side - so it's just pretty standard Delphi stuff, no Javscript etc required. In one application we have tablets out in the field returning HTML data to the server. When the UNIGUI user browses the list of returned files we check to see if the same file name exists but with a PDF extension rather than HTM - if not we simply call wkhtmltopdf.exe from a procedure in mainmodule in a hidden window with param1 as source html and param2 as the required PDF. Once the PDF does exist we display/print as required. you could use any Delphi function that runs an external exe (ShellExecute, ShellExecureEx, WinExec, CreateProcess....) This approach works fine for us, it's easy to implement and allows additional processing if the called process is actually a batch file with a list of other things to do in it, rather than just converting to a PDF. Cheers 1 Quote Link to comment Share on other sites More sharing options...
jrp Posted September 8, 2022 Author Share Posted September 8, 2022 Thank you Harry Rogers Quote Link to comment Share on other sites More sharing options...
picyka Posted March 16 Share Posted March 16 Em 07/09/2022 às 11:18, Harry Rogers disse: Todo o nosso trabalho é feito do lado do servidor - por isso é apenas coisas Delphi bastante padrão, sem Javscript etc necessário. Em um aplicativo, temos tablets em campo retornando dados HTML para o servidor. Quando o usuário UNIGUI navega na lista de arquivos retornados, verificamos se o mesmo nome de arquivo existe, mas com uma extensão PDF em vez de HTM - se não, simplesmente chamamos wkhtmltopdf.exe de um procedimento no mainmodule em uma janela oculta com param1 como html de origem e param2 como o PDF necessário. Uma vez que o PDF existe, exibimos/imprimimos conforme necessário. você pode usar qualquer função Delphi que execute um exe externo (ShellExecute, ShellExecureEx, WinExec, CreateProcess....) Essa abordagem funciona bem para nós, é fácil de implementar e permite processamento adicional se o processo chamado for realmente um arquivo em lote com uma lista de outras coisas para fazer nele, em vez de apenas converter para um PDF. Obrigada Hello, can you post an example of how to use it? Quote Link to comment Share on other sites More sharing options...
picyka Posted March 16 Share Posted March 16 GitHub - lminuti/Delphi-WkHtmlToX: Delphi implementation of WkHtmlToPdf API I tried to use this project with the dll, but on my api server, it works once, then there is an error and it doesn't work anymore. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.