Profile Picture

Crash when trying to print on multiple pages

Posted By PANOS PARTHENIADIS 15 Years Ago
Author
Message
PANOS PARTHENIADIS
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 1, Visits: 1
Hello,

I used to be a registered user for Nevron Diagram. I'm in the process of renewing my subscription, nevertheless i have a serious problem which prevents me of doing it at the moment.

When i try to print a diagram in multiple pages, the relevant dialog is presented saying "Generating Previews....Page X...." and it crashes with the following error. I attach the xml layout of the problematic diagram.

Please help! This is a serious error and i need a fix!

A generic error occurred in GDI+.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
at Nevron.GraphicsCore.l1lll1III.l11ll1lIII(NRectangleF& bounds)
at Nevron.GraphicsCore.l1111II11.Paint(Rectangle boundsInPixels)
at Nevron.GraphicsCore.lI11Illl1.PaintInternal(Rectangle bounds, lIllII1 callback)
at Nevron.GraphicsCore.lI11Illl1.PaintInternal(Rectangle bounds, lIllII1 callback)
at Nevron.GraphicsCore.lI11Illl1.PaintInternal(Rectangle bounds, lIllII1 callback)
at Nevron.GraphicsCore.lI11Illl1.PaintInternal(Rectangle bounds, lIllII1 callback)
at Nevron.GraphicsCore.lI11Illl1.Paint(Rectangle bounds, lIllII1 callback)
at Nevron.GraphicsCore.l1lll1III.l1lI1IlIl1(NRectangleF& bounds, l111IllIlI callback)
at Nevron.GraphicsCore.l1lll1III.l1lll1l11l(NRectangleF& bounds, GraphicsPath path)
at Nevron.GraphicsCore.l1I11l1l1I.PaintPath(GraphicsPath path)
at Nevron.GraphicsCore.l1llI1I1Il.PaintPath(GraphicsPath path)
at Nevron.Diagram.NPathPrimitive.PaintOpenFigureShadow(NPaintContext context, GraphicsPath path, NShadowStyle shadowStyle, NStrokeStyle strokeStyle, NArrowheadStyle startAHStyle, NArrowheadStyle endAHStyle)
at Nevron.Diagram.NPathPrimitive.PaintOpenFigure(NPaintContext context)
at Nevron.Diagram.NPolylinePath.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.Paint(NPaintContext context)
at Nevron.Diagram.NAggregateModel.Paint(NPaintContext context)
at Nevron.Diagram.NShape.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.Paint(NPaintContext context)
at Nevron.Diagram.NShapeCollection.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.Paint(NPaintContext context)
at Nevron.Diagram.NAggregateModel.Paint(NPaintContext context)
at Nevron.Diagram.NShape.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.Paint(NPaintContext context)
at Nevron.Diagram.NLayer.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.Paint(NPaintContext context)
at Nevron.Diagram.NLayerCollection.Paint(NPaintContext context)
at Nevron.Diagram.NDiagramElementCompositeImpl.SplitPaint(NPaintContext context)
at Nevron.Diagram.NDrawingDocument.Paint(NPaintContext context)
at Nevron.Diagram.Extensions.NCanvas.Paint(l11IIl1111 device, PaintReason reason)
at Nevron.Diagram.Extensions.NPrintDocument.OnPrintPage(PrintPageEventArgs e)
at System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e)
at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at System.Windows.Forms.PrintPreviewControl.ComputePreview()
at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.PrintPreviewControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at Nevron.Editors.NHostableUserControl.ShowInHostForm()
at Nevron.Diagram.Extensions.NPrintManager.ShowPrintPreview()
at WorkflowDiagramDesigner.WorkflowDiagramDesignerForm.printDiagram()



Attachments
layout.xml (114 views, 542.00 KB)
bob milanov
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

Hi Panos,

The problem is generally caused (as stated by Christo), by the image filters used in certain types of shadow and it is a problem with the MS Print Preview. In detail the problem is that GDI+ does not have a good way to render image filters so we do it ourselves using custom image processing - this greatly improves the looks of the component, but has a drawback when rendering large images (which is the case in printers where a typical image on the screen is stretched by factor of 6 (on a 600dpi printer) thereby increasing the rendering complexity for filters by a factor of 36. This is partially overcome in the latest SP of the componet, but some more work remains - MS have done a very poor job with the extended metafiles and we'll have to find a way not to use them.

For the time being I would recommend you to turn off image filters prior printing. This can easily be achieved using the following code (sorry about the formatting Word is a mess):

using Nevron.Diagram.Filters;
using Nevron.Diagram.Extensions;
using Nevron.Diagram.WinForm;
using Nevron.Diagram;
using Nevron.GraphicsCore;
 
private void PrintPreviewButton_Click(object sender, EventArgs e)
{
 MemoryStream stream = new MemoryStream();

 // save to stream
 NPersistencyManager manager = new NPersistencyManager();
 manager.PersistentDocument.Sections.Add(new NPersistentSection("Document", nDrawingDocument1));
 manager.SaveToStream(stream, Nevron.Serialization.PersistencyFormat.Binary, null);

 // load from stream
 stream.Seek(0, SeekOrigin.Begin);
       manager.LoadFromStream(stream, Nevron.Serialization.PersistencyFormat.Binary, null);

 NDrawingDocument printDrawing = manager.PersistentDocument.Sections[0].Object as NDrawingDocument;
 NShadowStyle shadowStyle;
 NFillStyle fillStyle;

 // traverse nodes etc.
 foreach (INStyleable shape in printDrawing.Descendants(NFilters.TypeINStyleable, -1))
 {
  NStyle style = shape.Style;

  if (style == null)
          continue;

  shadowStyle = style.ShadowStyle;

  if (shadowStyle != null)
  {
   // make sure shadow style does not use filters
   shadowStyle.Type = ShadowType.Solid;
   shadowStyle.Color = Color.FromArgb((int)(shadowStyle.Color.A * 0.8), shadowStyle.Color);
  }

                fillStyle = style.FillStyle;
  if (fillStyle != null)
  {
   // make sure fill style does not use filters
   fillStyle.ImageFiltersStyle = null;
  }

 }

 // do not forget to turn of shadow and image filters on document level
 shadowStyle = printDrawing.Style.ShadowStyle;
 if (shadowStyle != null)
 {
  // make sure shadow style does not use filters
  shadowStyle.Type = ShadowType.Solid;
  shadowStyle.Color = Color.FromArgb((int)(shadowStyle.Color.A * 0.8), shadowStyle.Color);
 }

 fillStyle = printDrawing.Style.FillStyle;

 if (fillStyle != null)
 {
  fillStyle.ImageFiltersStyle = null;
 }

 NPrintManager printManager = new NPrintManager(printDrawing);
 printManager.ShowPrintPreview();
}

The idea of the code is first to create a clone of the document, and then to modify it so that all shadows are made solid (instead of linear / gaussian blurred). This will increase the performance dramatically. BTW if you download the latest SP of the component it can display the document with image filters, but again it will be slow.

Hope I helped – let me know if you have any questions or meet any problems.

Best Regards,
Bob





Similar Topics


Reading This Topic