I'm doing this: I want to generate as pdf's as invoices and send them by e-mail
.
.
REPEAT
SetPdf;
Report.RUN(206,FALSE,TRUE,SalesInvoiceHeader);
IF (NOT EXISTS(MyFile)) AND (CONT < 5) THEN BEGIN
SLEEP(3000);
CONT := CONT + 1;
END;
IF EXISTS(MyFile) THEN
SendMail;
ClearMyPdf;
UNTIL SalesInvoiceHeader.NEXT = 0;
In SetPdf i set up the pdf
In SendMail, i Attachment the file and send it.
In ClearMyPdf, i clear pdf
But the problem is sometimes some pdf hasn't been created, i think that the problem is that i don't put PdfCreator.cClose, but i can't to put it because doesn't run. Do you know something about it?
First of all well done ara3n for your coding. Just one question pls. How can I attach another pdf to the background? There should be a field for sure but I still can't find a list of fields available anywhere.
I have a problem, and I need help. I want to save my pdf file directly to NAV 5.1 database table after create it. It is possible?
I create a BLOP type in a table.
Thx for the answer!
It's works!
Only one question: the pdf file exists in the file system. It is possible, that the file is not generated in the file system? i want to only my NAV database.
the new PDFCreator 0.98 gives me some headaches too.
I just noticed that the new PDFCreator ignores the Options set. PDFCreator didn't do anything and when I switched to the PDFCreator window it asked me some options and then created the PDF without error. The problem was that I set these options by code.
You now need to use the PDFCreator.cSaveOptions(); so that the options you set are really used!!!
Does PDFCreator allow you to add an overlay? I am experimenting with novaPDF, which is not free, but I had very quick positive results with their software. It also allows me to create pdf's programatically within NAV using a COM object. And based on the report I run, I can choose different overlays to add as a background to the document.
you can try and use report selection in NAV. set the report to print to specific printer.
Ok, but what if you want to use the same report (like sales confirmation) to print and send as pdf?
Then, you'll have to manually change the printer when you print the report...
Create a duplicate of the report just to print as pdf?
Comments
REPORT.RUN(ReportSelection."Report ID",False,True,SalesInvHeader);
then the Request Form is activate.
If i do this:
REPORT.RUN(ReportSelection."Report ID",True,True,SalesInvHeader);
Then the Request Form isn't activate but the default printer is changed to PdfCreator and then there isn't a print.
In in the PdfCreator i don't see the print.
PDFCreatorOption := PDFCreator.cOptions;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
PDFCreatorOption.AutosaveDirectory := FileDirectory;
PDFCreatorOption.AutosaveFormat := 0;
PDFCreatorOption.AutosaveFilename := FileName;
PDFCreator.cOptions := PDFCreatorOption;
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;
REPORT.RUNMODAL(ReportID,FALSE,TRUE);
But my problem is that my Default printer is changed to PdfCreator printer, do you know to change again in code to my old default printer.
PDFCreator.cDefaultPrinter := DefaultPrinter;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I'm doing this: I want to generate as pdf's as invoices and send them by e-mail
.
.
REPEAT
SetPdf;
Report.RUN(206,FALSE,TRUE,SalesInvoiceHeader);
IF (NOT EXISTS(MyFile)) AND (CONT < 5) THEN BEGIN
SLEEP(3000);
CONT := CONT + 1;
END;
IF EXISTS(MyFile) THEN
SendMail;
ClearMyPdf;
UNTIL SalesInvoiceHeader.NEXT = 0;
In SetPdf i set up the pdf
In SendMail, i Attachment the file and send it.
In ClearMyPdf, i clear pdf
But the problem is sometimes some pdf hasn't been created, i think that the problem is that i don't put PdfCreator.cClose, but i can't to put it because doesn't run. Do you know something about it?
Report.runmodal
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I'm going to do a new form, with the errors, and in this form i'll try to generate the falure invoices to a pdf.
First of all well done ara3n for your coding. Just one question pls. How can I attach another pdf to the background? There should be a field for sure but I still can't find a list of fields available anywhere.
Best Regards,
Steve
I have managed to create the background but I would like to get the pdf from a picture in navision, do you think this is possible?
Best Regards,
sabzam
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I have a problem, and I need help. I want to save my pdf file directly to NAV 5.1 database table after create it. It is possible?
I create a BLOP type in a table.
Thx!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
But how? I've tried to search pdfcreator option like .AutosaveDirectory, but I find nothing.
Gegii
Once the pdf file is created, you need to save the file into blob file.
MyBlob.save('C:\mypdffile.pdf\,false);
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
It's works!
Only one question: the pdf file exists in the file system. It is possible, that the file is not generated in the file system? i want to only my NAV database.
regards, Gegii
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
when I try to save a pdf I now get the PDFCreator options screen while I would like this to go silent. Is there something wrong in my code?
onderaannemerslijstREC.SETFILTER("Job No.","Job No.");
onderaannemerslijstREC.SETFILTER(Aktie, 'Calculator');
datum := FORMAT(TODAY);
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;
IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + PDFCreatorError.Description);
PDFCreatorOption := PDFCreator.cOptions;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
Temppath := ENVIRON('TEMP');
filename := "Job No." + ' ' + 'Calculator' + ' ' + datum +'.pdf';
PDFCreatorOption.AutosaveDirectory := Temppath;
PDFCreatorOption.AutosaveFormat := 0; PDFCreatorOption.AutosaveFilename := filename;
PDFCreator.cOptions := PDFCreatorOption;
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;
REPORT.RUN(78726,FALSE,FALSE,onderaannemerslijstREC);
PDFCreator.cDefaultPrinter := DefaultPrinter;
PDFCreator.cClose;
CLEAR(PDFCreatorOption);
CLEAR(PDFCreator);
CLEAR(PDFCreatorError);
the new PDFCreator 0.98 gives me some headaches too.
I just noticed that the new PDFCreator ignores the Options set. PDFCreator didn't do anything and when I switched to the PDFCreator window it asked me some options and then created the PDF without error. The problem was that I set these options by code.
You now need to use the PDFCreator.cSaveOptions(); so that the options you set are really used!!!
Regards,
Karsten
MCP - Dynamics NAV Developer
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
http://mibuso.com/blogs/ara3n/2008/08/
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Ok, but what if you want to use the same report (like sales confirmation) to print and send as pdf?
Then, you'll have to manually change the printer when you print the report...
Create a duplicate of the report just to print as pdf?
Then afterwords delete the record.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n