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();
element.printJobSettings().setTarget(PrintMedium::File);
element.printJobSettings().paperOrientation(PrinterOrientation::Landscape);
element.printJobSettings().fileName(“C:\Temp\custlist2.Txt”);

tb=new TextBuffer();
tb.setText("");
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;
}

regards

dhinu.v

Hi,

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 http://msdn.microsoft.com/en-us/library/bb190039(v=ax.10).aspx 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.