08-23-2012 10:45 AM
I have code complied under LabWindows 2009 that is working, but when I complie it under LabWindows 2010 it stops working.
I am trying to create pdfs using Adobe Distiller, functions like PrintPanel and PrintTextBuffer work in both 2009 and 2010. However,
NIReport_Print only works in 2009, if I try to print to Adobe. It works printing to a real printer.
I have attached the code the works and doesn't work.
/* print report to the default real printer - THIS WORKS */
  if(!iLocalFail)
   iLocalFail = Report_ErrorHandler(NIReport_Print(iReportHandle, NULL, 1), "Report Print");
/* set printer to adobe pdf to create pdfs */
  iLocalFail = SetPrintAttribute(ATTR_PRINTER_NAME, "Adobe PDF");
  if(iLocalFail < 0)
   printf("SetPrintAttribute was %d\n%s\n", iLocalFail, GetUILErrorString(iLocalFail));
/* create the key for the buffer test */   
  if(!iLocalFail)
   {
     sprintf(caFilenameWithPathInfo, "%sBuffer_%s.pdf", TEST_DIRECTORY, caMyTime);
    iLocalFail = RegWriteString(REGKEY_HKCU, ADOBE_KEY, ADOBE_NAME, (unsigned char * ) caFilenameWithPathInfo);
    if(iLocalFail < 0)
     {
      sprintf(caMessage, "RegWriteString Failed.\n, Error was %d.\n%s\n", iLocalFail, GetGeneralErrorString(iLocalFail));
      MessagePopup("RegWriteString", caMessage);
      iLocalFail = TRUE;
     }
    else
     printf("Printing Buffer\n");
   }
/*THIS WORKS */
/* read a dummy file to get data into a buffer and then print to the adobe printer */
  iFileHandle = OpenFile("c:\\mfgtests\\pdf_tester\\globals.h", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
  if(iFileHandle > 0)
   {
    ReadFile(iFileHandle, caBuffer, 50000);
    PrintTextBuffer(caBuffer, "");     /* "" for printer becasue of SetPrintAttribute */
   }
   
/* create the key for the panel test */   
  if(!iLocalFail)
   {
    sprintf(caFilenameWithPathInfo, "%sPanel_%s.pdf", TEST_DIRECTORY, caMyTime);
    iLocalFail = RegWriteString(REGKEY_HKCU, ADOBE_KEY, ADOBE_NAME, (unsigned char * ) caFilenameWithPathInfo);
    if(iLocalFail < 0)
     {
      sprintf(caMessage, "RegWriteString Failed.\n, Error was %d.\n%s\n", iLocalFail, GetGeneralErrorString(iLocalFail));
      MessagePopup("RegWriteString", caMessage);
      iLocalFail = TRUE;
     }
    else
     printf("Printing %s\n", caFilenameWithPathInfo);
   }
/* THIS WORKS */
/* print the panel, NULL for printer because of SetPrintAttribute */
  iLocalFail = PrintPanel(ghMainPanel, NULL, 1, VAL_FULL_PANEL, 0);
  if(iLocalFail < 0)
   {
    sprintf(caMessage, "Error was %d.\n%s\n", iLocalFail, GetUILErrorString(iLocalFail)); 
    MessagePopup("Print Panel Failed", caMessage);
   }
   
/* create the key for the report test */   
  if(!iLocalFail)
   {
    sprintf(caFilenameWithPathInfo, "%sReport_%s.pdf", TEST_DIRECTORY, caMyTime);
    iLocalFail = RegWriteString(REGKEY_HKCU, ADOBE_KEY, ADOBE_NAME, (unsigned char * ) caFilenameWithPathInfo);
    if(iLocalFail < 0)
     {
      sprintf(caMessage, "RegWriteString Failed.\n, Error was %d.\n%s\n", iLocalFail, GetGeneralErrorString(iLocalFail));
      MessagePopup("RegWriteString", caMessage);
      iLocalFail = TRUE;
     }
    else
     printf("Report Handle %d Printing %s\n", iReportHandle, caFilenameWithPathInfo);
   }
   
/* THIS DOESN'T WORK */   
/* print the report, NULL for printer because of SetPrintAttribute */
  if(!iLocalFail)
   iLocalFail = Report_ErrorHandler(NIReport_Print(iReportHandle, NULL, 1), "Report Print");
  printf("Done\n");
  NIReport_Discard(iReportHandle);
Solved! Go to Solution.
08-27-2012 02:17 PM
Hi Paul,
Are you receiving any specific errors? Could you post a screen shot of it if you are getting one? That would help us understand what is happening a little better. Thanks.
Regards,
Perry S.
08-28-2012 08:08 AM
There is no error message from either the code or the print queue. Watching the print queue, the file flashes in the queue.
09-17-2012 12:10 PM
It seems like NI_ReportPrint is the only function that has a problem with creating pdfs. WordRpt_Print, PrintTextBuffer, PrintPanel and PrintTextFile all automatically create PDFs using the Abode SDK. So I am going to use WordRpt and not NI_Report from now on.
So if you need PDFs created, don't use NI_Report.