LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NIReport_Print LabWindows 2009 vs 2010

Solved!
Go to solution

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);

 

0 Kudos
Message 1 of 4
(3,366 Views)

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.

Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,347 Views)

There is no error message from either the code or the print queue.  Watching the print queue, the file flashes in the queue.

0 Kudos
Message 3 of 4
(3,336 Views)
Solution
Accepted by topic author Paul_Knight_Lockheed_Mart

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.

0 Kudos
Message 4 of 4
(3,315 Views)