Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Print to File (PDF) , onGetFileSuffix , Unable to open file : _.pdf , only on Terminal Server

Dear Support,

I have a Windows 2012 Terminal Server. If I run my Programm from c:\Ladeliste it works. If I run my Programm from c:\Program Files (x86) or c:\Programme I always get the error : Unable to open file : _.pdf . If I run it as administrator it works.

Can you please help me?
procedure ABGroupOnGetFileSuffix(var SuffixValue: String);
begin

  SuffixValue :=  Report.Parameters['FilePath']+IntToStr(POS['AB']);

end;
I run this RTM from code like this :
 SelectedPrinter:=Printer.Printers[Printer.PrinterIndex];

  ReportBuilder.ppPrint.Template.FileName:=ReportPath+'Standard\EINZEL_LIEFERSCHEIN.rtm';
  ReportBuilder.ppPrint.Template.LoadFromFile;
  ReportBuilder.ppPrint.Parameters.Items['HeadID'].Value:=DataLief.qryHeadLieferscheinID.Value;
  ReportBuilder.ppPrint.Parameters.Items['TripID'].Value:=DataLief.qryPrintID.Value;
  ReportBuilder.ppPrint.Parameters.Items['D3'].Value:=0;
  ReportBuilder.ppPrint.Parameters.Items['Gestell'].Value:='%';


  ReportBuilder.ppPrint.Parameters.Items['FilePath'].Value:=TempPath;
  ReportBuilder.ppPrint.TextFileName:='_';

  ReportBuilder.ppPrint.ShowPrintDialog:=false;
  ReportBuilder.ppPrint.PrinterSetup.PrinterName:=SelectedPrinter;

  ReportBuilder.ppPrint.AllowPrintToFile:=true;
  ReportBuilder.ppPrint.DeviceType:= dtPDF;

  ReportBuilder.ppPrint.Print;

Comments

  • TempPath is C:\Users\johndoe\AppData\Roaming\RSoftware\TransportXLR\Temp\
  • edited February 2022
    If I use :
    ReportBuilder.ppPrint.TextFileName:=TempPath+'test.pdf';
    and comment out inside the RTM the ABGroupOnGetFileSuffix it works.

    But now every file has test_Ordernumber.pdf ( test_ is there , this was the main reason for TextFileName := '_';

    This same problem also happens with 21.03 , I use 20.03 . I guess I am doing something horribly wrong here, but what?

    NOTE : software does work without problem from Network Drive . Only if Software is located under c:\Program Files (x86) or c:\Programme it does not work if I do not explicitly set the TextFileName with fullpath to the Users Home Dir ( TempPath )
  • I think I have located my problem , but don't know how to solve:

    if I use TextFileName:='_.pdf'; . ReportBuilder tries to create the temporary file inside the folder where the App Executable is . So in my case c:\Program Files(x86)\Ladeliste\_.pdf this failes naturally since I cannot give every user admin rights.

    If I run it as admin it creates the _pdf there then it copies/renames it to the final order which is users home dir.

    So my question is , how do I tell report builder to create _.pdf file as well inside the Home Directory . Is there another setting I am missing?
  • I think I solved it :

    ReportBuilder.ppPrint.TextFileName:=TempPath+'_';

    Now the _.pdf empty file is created on the TempPath . And after the Report processes the data the files are correctly created as expected.

    Thank you.
Sign In or Register to comment.