Dear folks, I've asked this problem long ago but I left it because I can't find the solution. I used the search to find information about creating documents in pdf but I want to take my code to do it.
I've a commmand button on Sales Order form that, on pushing it, creates the sales order in html format and automatically insert it in a mail, and it runs perfectly; but now I want to do it in pdf format. I've Adobe Acrobat 8 Professional installed and I want to use it. This is the code in OnPush trigger:
RecOrder.RESET;
RecOrder.SETRANGE("Document Type","Document Type");
RecOrder.SETRANGE("No.","No.");
IF RecOrder.FIND('-') THEN BEGIN
IF RecCustomer.GET("Bill-to Customer No.") THEN BEGIN
rptOrder.SETTABLEVIEW(RecQuote);
rptOrder.SAVEASHTML('C:\Sales order.html');
SLEEP(2000);
CodeMail.NewMessage(RecCustomer."E-Mail",'','SALES ODER' + "No.",
'We send your sales order ' + "No.",'C:\Sales order.html',TRUE);
END;
END;
RecOrder is Sales Header table
rptOrder is my "Order confirmation" report
RecCustomer is Customer table
CodeMail is the codeunit Mail
Does anybody know how I cant create it using Adobe acrobat?.
Thanks in advance for help.
Comments
On another note, there are a few issues with your code.
1) The output file name is hard coded, and the file is not deleted afterward. If there was a problem overwriting that file, you might mistakenly send another customer's invoice to that customer.
2) Don't just do a SLEEP for a certain amount of time. You never know if some other process is going to come along and steal your CPU. Query the File table to see if the file has been created. If it hasn't, THEN do a sleep for a few seconds and try again. You'll need a maximum time that you want to keep looking for it.
My Blog - nav.education
But, by now, I don't want to install another software printer, I'll have to install in every user, I want to use Acrobat; is ther any way to use it?.
Thanks for help.
Thanks.
Thanks for reply.
or option to automatically save the printed documents into a folder.
You have to change your code to print the report, and assume that the adobe is the default printer.
Afterwords keep monitoring the folder and see that the pdf file is created and that you can change the datetime on it (this means the printing is done);
then you can attach it to your email.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
This is the problem, now, on save in html format is easy, I put file.SAVEASHTML('C:\file.html'); and after put it in a mail; but I don't know what is the code on printing it in pdf format.
Thanks for help.
REPORT.RUNMODAL(Number [, ReqWindow = false] [, SystemPrinter = true] [, Record with filters]);
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks for help.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thank you very much for your help.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks for help.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks for help.
MyFolder datatype = record, subtype File
clear(MyFolder);
MyFolder.setrange("Directory",'c:\someFolder');
MyFolder.setrange("is file",true);
MyFolder.setfilter(Name,'*.pdf');
if MyFolder.findfirst
message(MyFolder.Name);
There are other examples on this website for find a file in a folder.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks again.
I understood the problem and solution both, but can you tell me which printer should i use which will save my file in a pdf format automatically?
Is it a freeware or we need to buy a licensed version? Pls Help
Thnx
Navision Developer
Acrobat pdf printer i believe you need to purchase.
Bullzip is freeware for up to 10 people.
PDFCreator is freeware.
CutePDF is not free
PDF95 is not free.
There are several threads on each pdf printer
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I've been trying to automatically send orders to customers for weeks.
Regards,
N