BullZipPDF - Generating and Emailing

kaybeekaybee Member Posts: 49
Hi, I understand there are loads of threads on this. But is there a way of printing to the BullZip PDF printer without the need of having to set the BullZipPDF as the default printer or having it in the printer selection table? As obviously I need to not only be able to email it but also for the users to manually print it to a hard printer.

The following is my function:
Dlg.OPEN('Preparing Document...');
IF ISCLEAR(BullZipPDF) THEN CREATE(BullZipPDF);
FileDirectory := ENVIRON('TEMP') + '\' {Text001};
FileName := xFileName;
IF EXISTS(FileDirectory+FileName) THEN
  IF NOT ERASE(FileDirectory+FileName) THEN
    FileName := FORMAT(TODAY, 0, '<day><month><year>') + FORMAT(TIME, 0, '<Hours24><Minutes,2><Seconds>') + xFileName;
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);

TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
  SLEEP(100); //was 1000.
  TimeOut := TimeOut + 1;
END;
Dlg.CLOSE;
EXIT(FileDirectory+FileName);

I also have a problem in the above, users often modify the sales line, so the order report should effectively be updated when they click to create the PDF again, however they are always emailed the cached version of the PDF document from the previous call. So in the above, I simply append date and timestamps to the filename, so that it keeps generating a unique file for attachment.

Realistically, it should delete the file, but it keeps saying "Error deleting, file in use".

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    kaybee wrote:
    But is there a way of printing to the BullZip PDF printer without the need of having to set the BullZipPDF as the default printer or having it in the printer selection table?
    When people click your button or menu item to generate the pdf-file, you could add code that creates the record in the Printer Selection table, runs your report and afterwards deletes the record in the Printer Selection table. Or you could add code in Codeunit 1, function FindPrinter, to return the value "Bullzip PDF Printer" when a certain condition is met, without looking up the printername in the already mentioned table.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • kinekine Member Posts: 12,562
    You need to check that the generatin process finished and the file is available for other processes. It was already solved on the forum. Principle is simple: try to open the file for writing. If Succeeded, finished. If not, still generating the file...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.