Print from a Textbuffer/TextFile

Hi all,

while am executing the report which consists of the following code gives error

"Request for the permission of type FileIOPermission failed ",

i have to print data directly from text file,pls give the solution.

public int print()
PrintMgmtPrintSettingDetail detail = purchFormLetterReport.getCurrentPrintSetting();
PurchTable PurchTable;
TextBuffer tb;
fileName fileName;
fileIOPermission fileIOPermission;
int ret;

ret = super();

printJobSettings = new PrintJobSettings();

tb=new TextBuffer();
tb.fromFile(“C:\Temp\custlist2.Txt”); //data sd tak from custlist2.txt file
tb.toFile(“lpt1:”); //lpt1 is the printername

return detail && detail.validatePrinterDestination() ? super() : 0;
return ret;




right click on ur text file on the properties → Security tab check whether all the options are been enabled for the logged user for that particular file.

And check this link if you can get any solution for the FileIOpermission if you are using 4.0

Hi Dhinu,

Most of the time there are rights issue for accessing a file from a application in C: \ folder

If you change the path to D: drive then this should work fine.