Hi,
I found a lot of topics which explain how to print report to pdf but didn't find exact solution for my idea. I want to print report to pdf through code using freeware software. At the moment I started with solution where in first step I'll save report as html then using htmldoc program (which is freeware and allows run it from command line with different parameters) converting it to pdf. As htmldoc program has some problems with blank textboxes (after converting shows symbols  ) I also had to run program that deletes these symbols before converting. The whole process together is a little bit clumsy (save as html then remove   symbols with external program then converting to pdf with external program - htmldoc) and I want to improve it.
Can somebody suggest some programs for printing reports directly to pdf which are freeware and have included ocx or automation server.
Thanks in advance,
Anti
0
Comments
2) Saving report into PDF has 3 main problems:
a) You need to say to the PDF printer where you want to save the PDF and the filename of the PDF
b) You need to select the PDF printer for the report you want to print
c) You need to check if the PDF is created or not to continue with your code (and to be able to attach the PDF to mail etc.)
a) The automation solve that, you can turn on the auto-save and set the directory and filename in PDFCreator
b) You can change the CU1 function for selecting printer to return PDFCreator printer when you are printing into PDF through code (you just needs to pass the parameter into CU1 - see howto's for how to pass parameters between objects) - in this case you do not need to set default printer to PDFCreator or set the printer for the report in Printer selection table.
c) PDFCreator automation has one Event which is fired when printing was finished (and second when error was called). But you needs to find solution how to wait for that trigger and not block NAV by some loop, else the trigger will be not fired... (I am using modal form with timer checking some flag which is set by the trigger)
I am not allowed to post you the code or example of it, but this is the general description what you need to solve.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
http://www.mibuso.com/forum/viewtopic.php?t=18331&highlight=
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I've got PDFCreator testversion for Vista and were now able to test this solution. As kine said there are three main problems to solve in saving report to pdf. I used the example code: http://www.mibuso.com/forum/viewtopic.p ... highlight= but didn't manage to save file automatically. Maybe the problem is in PDFCreator Vista version. Finally I changed PDFCreator autosave options in settings file and solved the problem this way. Printer selection wasn't the problem but then I stucked on last problem. I used trigger PDFCreator::eReady() to close PDFCreator and change back to default printer. But sometimes there is a problem with closing PDFCreator and then I get an error "An instance of PDFCreator is already running". CLEAR(PFCreator) clears variable but when PDFCreator monitor is still running it gives me such an error message. I tried to put sleep-function to wait some time before starting with next report but how should I know how long to wait (it can vary a lot). Do you have any suggestions how to solve it.
Thanks in advance,
Anti
I really appreciate your help!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I'm using pdfCreator to generate pdf file, i'm facing strange circumstance where sometimes the coding work well but sometimes the pdf file can't save automatically although i already specify the filePath & fileName.
When the time it can't save automatically pdfCreator prompt me a screen ask me to enter keyword, subject, author... This was really annoying...
Do any 1 hv tis kind of experience b4? Any solution???
Below is my code:
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
filedir := 'C:\sentbox';
filename := "Sales Invoice Header"."No."+'.pdf';
PDFCreatorError := PDFCreator.cError;
IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + PDFCreatorError.Description);
PDFCreatorOption := PDFCreator.cOptions;
PDFCreatorOption.AutosaveDirectory := filedir;
PDFCreatorOption.AutosaveFilename := filename;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
PDFCreatorOption.AutosaveFormat := 0;
PDFCreator.cOptions := PDFCreatorOption;
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;
mycust.RESET;
mycust.SETRANGE(mycust."No.","Sales Invoice Header"."Sell-to Customer No.");
IF mycust.FIND('-') THEN BEGIN
IF mycust."E-Mail" <> '' THEN BEGIN
mymail.NewMessage(mycust."E-Mail",'','Sales Invoice Report','Regards, teckpoh',
'C:\Sentbox\'+"Sales Invoice Header"."No." +'.pdf',
FALSE);
mymail.Send();
END;
END;
I had the exact same problem. I uninstalled PDFCreator, reinstalled and now it works fine.
I used PdfCreator to send an email and my problem is inside the email body how can i write a sentence that split into 2 row.
I used the code below:
IF mycust.FIND('-') THEN BEGIN
IF mycust."E-Mail" <> '' THEN BEGIN
mymail.NewMessage(mycust."E-Mail",'','Sales Invoice Report','Regards, +'\teckpoh',
mymail.Send();
but the result is
Regards, teckpoh
instead of :
Regard,
teckpoh
Any advise...? Thank in advance~~
Finally i solved it by using crlf function. Store the email body to array and in between the arrays break a new line with cr & lf
After uninstall and reinstall the problem still there..most of the time pdfcreator pop up the screen ...
or anybody is using other useful tool tat act as same as pdfcreator? plz tell me....10s a lot~~