Is there an easy way to create a PDF using CRMScript and save it as an attachment to the ticket ?
Create a PDF? Containing what?
Some context please :)
Thanks for replying Hans.
The PDF is supposed to have 2 parts.
1. Customer Information
2. Order details in table format.
we don't have a way to do it with only CRM Script.
We don't have a way to automatically create a PDF and attach it to the ticket in a background process.
Or there might be a way, by using NetServer to write to a Document Template (although I'm not so familiar with this approach).
Hi, you can do it by installing https://wkhtmltopdf.org/ on the same server as CS is installed. Then, create a webpage in Service with the content you want to PDF'ify. Next, call runProgram to call wkhtmltopdf, passing in the URL you want to create a PDF for.
Could it perhaps be easier to create an XPS-file in stead of a pdf?
A bit to "hardcore" for me, but doesn't a windows-server have standard components to create an XPS?
Just an idea....
I liked your idea Frode :)
Does a call to the program return a filepath or something that I can save in CS ?
when you call the wkhtmltopdf.exe file you also pass in a parameter which says where to put the file, and then you can use the File class in ejscript to read the file afterwards. Using that you can save it as an Attachment in Service.
I've set up a site on the same server as Service is installed:
After this I'm supposed to run a command like this:
wkhtmltopdf http://google.com f:\example.pdf
Is it supposed to be called via the URL? i.e http://localhost/pdfCreator/bin/wkhtmltopdf.exe "and the rest ..."
wktohtml is just installed like any other application on the server, and you don't need to do anything in IIS for it.
From CRMScript you just use the full path to the program, something like this:
String CreatePDFFromUrl(String url, String outputFullPath, String arguments)
//Requires wkhtmltopdf to be installed on the server (https://code.google.com/p/wkhtmltopdf/)
//If the PDF file already exists, then it will be overwritten
String pathToPdfGenerator = "\"c:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\" " + arguments;
String application = pathToPdfGenerator + " " + url + " " + outputFullPath;
String message = runProgram(application); //Note, executed as the application pool user.
if (message.find("Error") > 0)
return message.subString(message.find("Error"), 999);
Then call it by doing something like this:
CreatePDFFromUrl("http://url/to/service", "C:\\temp\\file.pdf", "");
Just tried it Frode. Worked like a charm.
Thank you very much !
FYI, if you want to create it from a Word file, you can build a small c# service that uses Word interops to convert it for you, and then read the base64 back into CRM/CS.
I used this link to get me started.
StängDenna webbplats använder cookies. Superoffice använder cookies främst för att övervaka trafiken på webbplatsen och för att optimera innehållet. Om du accepterar vår användning av cookies kan du fortsätta använda den här webbplatsen. Läs mer: Integritetspolicy