0
I’m creating a code that generates a txt to print to a printer matrix. However, I would like to change the font of the letters. Someone could help me, please?
Follow the code below.
try{
byte[] bytes;
using (MemoryStream memoryStream = new MemoryStream())
{
using (TextWriter textWriter = new StreamWriter(memoryStream))
{
string divisao = "=";
for(int i = 0; i < 79; i++)
{
divisao += "=";
}
foreach (eOA01 x in Lpdf)
{
textWriter.WriteLine(divisao);
textWriter.WriteLine("ENDERECO= " + x.ENDERECO);
textWriter.WriteLine(x.PORTA);
}
textWriter.Flush();
bytes = memoryStream.ToArray();
}
}
Button3.Enabled = false;
Response.Clear();
Response.ContentType = "application/force-download";
Response.AddHeader("content-disposition", "attachment; filename=OS" + DateTime.Now.ToString("dd/MM/yyyy") + "_" + DateTime.Now.ToString("HH:mm") + ".txt");
Response.BinaryWrite(bytes);
Response.End();
}
catch (Exception ex)
{
//porque ele está sendo usado por outro processo.
string err = ex.Message;
}
Thank you!
Archives
.txt
does not support styling, so you cannot change font size, color, style and family. Generate a PDF or create a file. RTF.– CypherPotato
I can change in Notepad. But via code then it must be unfeasible.
– Rafael Veloso
This is because you actually change the text display settings of the Notepad itself and not the typed/written text. For this as Cyberpotato said use an RTF file.
– Victor Laio
I get it, thank you!
– Rafael Veloso