Question:
I have a thermal printer to do some tests of printing badges with pvc cards.
At first I set up a badge template in ReportViewer and I'm generating it in pdf .
And apparently it is losing a lot of quality when I generate in this format.
I would like to know the best way to generate this badge and print it with this type of printer? Taking into account printing in the right way with this printer and getting quality.
Answer:
As I'm generating a PDF in an ASP.NET-MVC project, I'm using a method that renders the report and then makes it available to be viewed in the browser.
public FileContentResult RenderReport(string reportName, List<dynamic> data, string format = "PDF", string deviceInfo = "")
{
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Reports/" + reportName + ".rdlc");
// Passa os dados para o arquivo .xsd
ReportDataSource reportDataSource = new ReportDataSource(reportName, data);
localReport.DataSources.Add(reportDataSource);
format = format.ToUpper();
string mimeType;
string encoding;
string fileNameExtension;
if (Common.Strings.IsEmpty(deviceInfo))
{
deviceInfo = "<DeviceInfo>" +
" <OutputFormat>" + format + "</OutputFormat>" +
" <PageWidth>21cm</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>2cm</MarginTop>" +
" <MarginLeft>2cm</MarginLeft>" +
" <MarginRight>2cm</MarginRight>" +
" <MarginBottom>2cm</MarginBottom>" +
"</DeviceInfo>";
}
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localReport.Render(
format,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}
The last parameter of this method was added and then I set the default values for the card. Ready. With that, the card/badge started to be generated with quality.