You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until now, to print a user control to PDF I create a fixed document, a fixed page and I add the user control to the page. Then I call the print dialog to select the printer.
The problem is that if the use control has an image as backgruound, the Microsoft to PDF printer doesn't work, I get an empty page. So I was wondering if it is possible to use GhostScript to print user controls.
I look the examples, but I am not sure how I could print a user control.
The code that I am using until now is the following:
private void Imprimir()
{
ControlUsuarioParaImprimir miControlUsuarioParaImprimir = new ControlUsuarioParaImprimir();
FixedDocument miDocumento = new FixedDocument();
miControlUsuarioParaImprimir.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
miControlUsuarioParaImprimir.Arrange(new Rect(miControlUsuarioParaImprimir.DesiredSize));
miControlUsuarioParaImprimir.UpdateLayout();
Size miTamañoPagina = new Size(miControlUsuarioParaImprimir.ActualWidth, miControlUsuarioParaImprimir.ActualHeight);
FixedPage miPagina1 = new FixedPage();
miPagina1.Width = miTamañoPagina.Width;
miPagina1.Height = miTamañoPagina.Height;
miPagina1.Children.Add(miControlUsuarioParaImprimir);
PageContent miContenido1 = new PageContent();
((IAddChild)miContenido1).AddChild(miPagina1);
miDocumento.Pages.Add(miContenido1);
//From here, coud I use GhostScript to print my fixed document???
System.Windows.Controls.PrintDialog myDialog = new System.Windows.Controls.PrintDialog();
if (myDialog.ShowDialog() == true)
{
try
{
//Print the image.
myDialog.PrintDocument(miDocumento.DocumentPaginator, string.Empty);
}
catch
{
//@#MEJORAR: realmente una librería nunca debería tener un messagebox. Se tiene que lanzar una excepción.
MessageBox.Show("El documento no se ha podido crear.\r\n\r\n"
+ "Si está abierto y se está intentando sobreescribir, se recomienda cerrar el documento antes"
+ " de imprimirlo.");
}
}
}
Thanks.
The text was updated successfully, but these errors were encountered:
Until now, to print a user control to PDF I create a fixed document, a fixed page and I add the user control to the page. Then I call the print dialog to select the printer.
The problem is that if the use control has an image as backgruound, the Microsoft to PDF printer doesn't work, I get an empty page. So I was wondering if it is possible to use GhostScript to print user controls.
I look the examples, but I am not sure how I could print a user control.
The code that I am using until now is the following:
private void Imprimir()
{
ControlUsuarioParaImprimir miControlUsuarioParaImprimir = new ControlUsuarioParaImprimir();
Thanks.
The text was updated successfully, but these errors were encountered: