Runtime Error using RasterMode by pdf.AddPage()

writing a PDF from a picture in RhinoView, with rastermode true, get a Runtime Error. First writing is ok. Additional there is no error when it was run in a RhinoPlugin. Now, it should be executed directly and written several times. RhinoInside is using.

Code:

ViewHelper.GetCurrentView().ActiveViewport.SetProjection(DefinedViewportProjection.Top, "", true);
ViewHelper.ZoomExtendsAllViews();
ViewHelper.SetViewDisplayMode(ViewHelper.GetCurrentView(), DisplayModeDescription.GetDisplayMode(DisplayModeDescription.GhostedId));
 
var pdf = Rhino.FileIO.FilePdf.Create();
 
//A3 Size
var size = new System.Drawing.Size(2970, 4200);
int dpi = 254;
 
var viewCaptureSettings = new ViewCaptureSettings(activeView, size, dpi);
 
viewCaptureSettings.OutputColor = ViewCaptureSettings.ColorMode.DisplayColor;
viewCaptureSettings.SetModelScaleToValue(1.0);
viewCaptureSettings.RasterMode = true;
 
pdf.AddPage(viewCaptureSettings);
 
string filePath = folderPath + "\\ exportPDF.pdf";
 
pdf.Write(filePath);

Error:

System.Runtime.InteropServices.SEHException
  HResult=0x80004005
  Nachricht = Eine externe Komponente hat eine Ausnahme ausgelöst.
  Quelle = RhinoCommon
  Stapelüberwachung:
   bei UnsafeNativeMethods.CRhinoPrintInfo_VectorCapture(IntPtr constPrintInfo, SetClipRectProc clipRectProc, FillProc fillProc, VectorPolylineProc polylineCallback, VectorArcProc arcCallback, VectorStringProc stringCallback, VectorPolylineProc bezCallback, VectorFillPolygonProc fillPolyCallback, VectorPathProc pathCallback, VectorPointProc pointCallback, VectorBitmapProc bitmapCallback, VectorRoundedRectProc roundedRectCallback, VectorClipPathProc pathProc, VectorGradientProc gradientProc, UInt32 docSerialNumber)
   bei Rhino.Runtime.ViewCaptureWriter.Draw(IntPtr constPtrPrintInfo, RhinoDoc doc) in Rhino.Runtime\ViewCaptureWriter.cs: Zeile126
   bei ExportPDF.PdfDocumentWriter.AddPage(ViewCaptureSettings settings) in D:\BuildAgent\work\commercial\src4\rhino4\Plug-ins\export_PDF\ExportPDFPlugIn.cs: Zeile939
   bei Construction.Tools.PDFExportToolViewModel.ExportPDF() in C:\Users\...\UserControls\Construction\Tools\PDFExportToolViewModel.cs: Zeile369
   bei Construction.Tools.PDFExportToolViewModel.<get_ExportPDFCmd>b__32_0(Object param) in C:\Users\...\PDFExportToolViewModel.cs: Zeile252
   bei RelayCommand.Execute(Object parameter) in C:\Users\...\RelayCommand.cs: Zeile50
   bei MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   bei System.Windows.Controls.Primitives.ButtonBase.OnClick()
   bei System.Windows.Controls.Button.OnClick()
   bei System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   bei System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   bei System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   bei System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in MS.Win32\HwndWrapper.cs: Zeile221
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) in MS.Win32\HwndSubclass.cs: Zeile255
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) in System.Windows.Threading\ExceptionWrapper.cs: Zeile81
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) in System.Windows.Threading\ExceptionWrapper.cs: Zeile31
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) in System.Windows.Threading\Dispatcher.cs: Zeile1401
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) in MS.Win32\HwndSubclass.cs: Zeile207
   bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) in System.Windows.Threading\Dispatcher.cs: Zeile1720
   bei System.Windows.Application.RunDispatcher(Object ignore)
   bei System.Windows.Application.RunInternal(Window window)

Maybe there is a way to run the print multiple times, even if the raster mode is true?
I would be happy about any tip/idea. thank you very much.