Generate multiple PDF files from multiple HTML files

Hi, 


First the environment :

 - PDFCreator version 1.7.3
 - Windows 7 and Windows 8.1
 - C++Builder XE7 with COM Interface

I would print all HTML files in a folder to multiple PDF files. To do this I use COM Interface
The first HTML is correctly generated in PDF … but PDFCreator crash during generating the second files.

HTML files exists, are correct, and folder can be writing.

Is someone can help me to find the problem ?


Hi,


is this only related to the order of the files, e.g. it is always the second file that crashes, even if you swap the first 2 files?

best regards,


Yes it is always the second file that crashes


Hi,


please post the relevant snippet of code here  , so we or other users can have a look at it and see if there is potential problem with it. You could also try adding some delay between the 2 jobs in case it is a timing problem. Also enable logging in the PDF print monitor, it might give additional clues about whats going wrong.

best regards,


Here is my code :


void __fastcall PrintPDF(UnicodeString lpInFileName, UnicodeString DirOutFile, UnicodeString lpOutFileName)
{
   TclsPDFCreator* oPDFCreator = new TclsPDFCreator(NULL);
   oPDFCreator->Connect();
   oPDFCreator->cStart(L"/NoProcessingAtStartup", true);
   oPDFCreator->cVisible  = true;
   oPDFCreator->cPrinterStop = true;
   oPDFCreator->cClearCache();
   oPDFCreator->cDefaultPrinter = WideString(“PDFCreator”).c_bstr();

   _clsPDFCreatorOptionsPtr opt = oPDFCreator->get_cOptions();
   opt->UseAutosave = 1;
   opt->UseAutosaveDirectory = 1;
   opt->AutosaveFormat = 0; // ; 0=PDF, 1=PNG, 2=JPG, 3=BMP, 4=PCX, 5=TIFF, 6=PS, 7= EPS, 8=ASCII
   opt->AutosaveStartStandardProgram = 0;
   opt->UseStandardAuthor = 1;
   opt->StandardAuthor = L"";

   opt->AutosaveDirectory = WideString(DirOutFile).c_bstr();
   opt->AutosaveFilename = WideString(lpOutFileName).c_bstr();

   oPDFCreator->_set_cOptions(opt);
   oPDFCreator->cPrinterStop = false;

   oPDFCreator->cPrintURL(WideString(lpInFileName).c_bstr(), 100);

   while (oPDFCreator->cCountOfPrintjobs != 1)
   {
      Sleep(10);
      Application->ProcessMessages();
   }

   while (oPDFCreator->cCountOfPrintjobs != 0)
   {
      Sleep(10);
      Application->ProcessMessages();
   }

   oPDFCreator->cClearCache();
   oPDFCreator->cPrinterStop = true;
   oPDFCreator->cClearCache(); // Clean cache
   Application->ProcessMessages();
   VARIANT_BOOL bClose = oPDFCreator->cClose();
   Application->ProcessMessages();
   oPDFCreator->Disconnect();
   Sleep(500);
   delete oPDFCreator;
   Sleep(1500);
   Application->ProcessMessages();
}