Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
Problemas de RDLC en monitores con mayor escala recomendada

Estoy en .net framework 4.8 en mi aplicación WPF y tengo dos usos en RDLC. El primero es un ReportViewer completamente obtenido que usa un DataTable de postgres, el segundo es solo un Informe local con una pequeña cantidad de parámetros representados como EMF e impresos directamente con el uso de la impresora predeterminada.

Ambos tienen lo que parecería ser un problema de renderizado, pero solo en monitores que tienen una escala recomendada (RS)> 100%. El resultado es aplastar las letras verticalmente y agregar algo de espacio adicional en el medio (puedo proporcionar muestras tan pronto como vuelva a tener acceso a la máquina del cliente). Si solo aumento la escala en mi monitor 100% RS, todo se imprime bien. Si reemplazo el monitor >100% RS con uno de 1080p 100% RS, nuevamente, todo se imprime bien. Las impresiones en máquinas con monitores con >100 % de RS siempre salen desordenadas, independientemente de la escala que configuré en Windows. Los problemas se pueden reproducir rápidamente con solo la vista 'Diseño de impresión' en ReportViewer, exportar a PDF produce los mismos resultados.

Como tengo ReportViewer y una impresión directa de LocalReport, pude probar varios enfoques diferentes:

  • Hacer que la aplicación sea DPIAware/no consciente/verdadera/PM, etc. (también se incluyen cambios en el manifiesto, App.config y App.xaml)
  • Poner ReportViewer en ViewBox
  • Uso de DpiX/Y y PrintDpiX/Y en DeviceInfo
  • ScaleTransform y DrawImageUnscaled en la devolución de llamada de PrintPage con y sin los cambios de DeviceInfo
  • innumerables opciones de impresora en Windows

Las máquinas cliente se ejecutan en la última versión de Windows 10 o cerca de la última y, de lo contrario, están bastante vacías.

¿Te suena de algo? ¿Alguna idea para una posible solución?

Me encantaría usar RDLC en mi aplicación, por la simplicidad de desarrollo y uso, pero esos problemas son realmente un problema para la tecnología.

Código

Sin impresión de vista previa

Se utiliza para imprimir un solo documento directamente sin vista previa de los parámetros.

 class CytologiaPrinter : IDisposable { private static readonly ILog log = LogManager.GetLogger(typeof(CytologiaPrinter)); private int m_currentPageIndex; private IList<Stream> m_streams; private int WizytaID; private CytologiaAnkieta Cytologia; public CytologiaPrinter(int wizytaID) { WizytaID = wizytaID; } public CytologiaPrinter(CytologiaAnkieta cytologia) { Cytologia = cytologia; } public void Print() { try { CytologiaAnkieta cytologia; if (Cytologia == null) { cytologia = DBCommunication.fetchCytologia(WizytaID); } else { cytologia = Cytologia; } if (cytologia != null && cytologia.AnkietaNumer != null && cytologia.AnkietaNumer.Length > 0) { LocalReport report = new LocalReport(); var cytologie = new List<CytologiaAnkieta>(); cytologie.Add(cytologia); ReportDataSource reportDataSource = new ReportDataSource("DataSet1", cytologie); report.DataSources.Add(reportDataSource); report.ReportEmbeddedResource = "Suplement.CytologiaAnkieta.rdlc"; var parameters = new List<ReportParameter>(); //parameters.Add(...); //setting all parameters omitted for demo report.SetParameters(parameters); m_currentPageIndex = 0; Print(cytologia); } } catch (Exception ex) { log.Error("Error (" + ex.Message + "), stack:" + ex.StackTrace); } } private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; } private void Export(LocalReport report) { string deviceInfo = @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>29.7cm</PageWidth> <PageHeight>21cm</PageHeight> <MarginTop>1cm</MarginTop> <MarginLeft>1cm</MarginLeft> <MarginRight>1cm</MarginRight> <MarginBottom>1cm</MarginBottom> </DeviceInfo>"; //printing in landscape Warning[] warnings; m_streams = new List<Stream>(); report.Render("Image", deviceInfo, CreateStream, out warnings); if (warnings != null && warnings.Length > 0) { foreach (var warn in warnings) { log.Warn("Cytologia printing issues: " + warn.Message); } } foreach (Stream stream in m_streams) stream.Position = 0; } private void PrintPage(object sender, PrintPageEventArgs ev) { Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]); Rectangle adjustedRect = new Rectangle( ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX, ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY, ev.PageBounds.Width, ev.PageBounds.Height); ev.Graphics.FillRectangle(Brushes.White, adjustedRect); ev.Graphics.DrawImage(pageImage, adjustedRect); m_currentPageIndex++; ev.HasMorePages = m_currentPageIndex < m_streams.Count; } private void Print(CytologiaAnkieta cytologia) { if (m_streams == null || m_streams.Count == 0) throw new Exception("Error: no stream to print."); PrintDocument printDoc = new PrintDocument(); printDoc.DefaultPageSettings.Landscape = true; if (!printDoc.PrinterSettings.IsValid) { throw new Exception("Error: cannot find the default printer."); } else { printDoc.PrintPage += new PrintPageEventHandler(PrintPage); m_currentPageIndex = 0; printDoc.Print(); } } public void Dispose() { if (m_streams != null) { foreach (Stream stream in m_streams) stream.Close(); m_streams = null; } } }

Vista previa de WinForms

Xaml

 xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" ... <WindowsFormsHost DockPanel.Dock="Bottom" Margin="0 0 0 0" > <rv:ReportViewer x:Name="RVDemo"/> </WindowsFormsHost>

Parte del código C#

 private void RaportGenerate_Click(object sender, RoutedEventArgs e) { RVDemo.Reset(); ReportDataSource reportDataSource = new ReportDataSource("Ankiety", DBCommunication.fetchCytologiaAnkietyReport(...)); RVDemo.LocalReport.DataSources.Add(reportDataSource); RVDemo.LocalReport.ReportEmbeddedResource = "Suplement.Cytologie.rdlc"; var parameters = new List<ReportParameter>(); //parameters.Add(...); // omitted for demo RVDemo.LocalReport.SetParameters(parameters); RVDemo.RefreshReport(); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El problema es bien conocido, también afecta el rendimiento. La razón es simple:

RDLC fue creado para entregar informes simples como recibo o factura. cualquier cosa más que eso te va a causar muchos problemas y muchos dolores de cabeza.

Hay una solución simple que ofrece el soporte técnico de Microsoft en la web:

  • Cambiar la configuración de DPI del sistema
  • Cambiar la fuente en el informe
  • Haga que el visor de informes se adapte a una resolución más alta automáticamente.

Pero todos ellos simplemente ignoran el simple hecho de que RDLC nunca fue diseñado para grandes informes o resoluciones más altas. Solo para documentos como facturas o recibos que son modestos y con una pequeña cantidad de detalles para abordar

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!