I'm hoping somebody could shed some light on what can be done for this.
Here is the offending code:
Code: Select all
public void PrintDocument(string documentName, dynamic context, PrinterSettings printerSettings = null)
{
try
{
if (_cursor != null)
_cursor = Cursors.WaitCursor;
var docMgr = _spServer.GetService<IDocumentManager>();
var docInfo = docMgr.Documents.Where(x => x.Identifier.Name == documentName || x.Title == documentName).First();
var renderFactory = _spServer.GetService<IRendererFactory>();
var renderer = renderFactory.Create();
var rendering = (IRendering)renderer.Render(docInfo, context, null); // <----------Line where error gets thrown!!!
var pdfTools = _spServer.GetService<IPdfToolsProvider>();
if (printerSettings != null)
{
using (var pdfStream = rendering.Export(DocumentFormat.PortableDocumentFormat))
pdfTools.Print(printerSettings, pdfStream);
}
else
{
using (var printDialog = new PrintDialog())
{
if (_cursor != null)
_cursor = Cursors.Default;
if (printDialog.ShowDialog() == DialogResult.OK)
{
using (var pdfStream = rendering.Export(DocumentFormat.PortableDocumentFormat))
pdfTools.Print(printDialog.PrinterSettings, pdfStream);
}
}
}
}
catch (Exception ex)
{
ex.WriteLog();
ExceptionExtensions.Show(ex);
}
finally
{
if (_cursor != null)
_cursor = Cursors.Default;
}
}
private dynamic GetPrintingContext(IOrder order, string document)
{
switch (document)
{
case "PGP_150065_natInternalSearchWorksheet##":
return SoftProExtensions.GetFirstOrDefault(order, "Properties");
default:
return order;
}
}
Any insight would be appreciated, thanks in advance.The TXTextControl components are built with framework v2.0.50727. To load a component in the 4.0 runtime add an application configuration file to the project.
at ?..ctor()
at TXTextControl.ServerTextControl.Create()
at SoftPro.Documents.Rendering.TextControl.ServerFactory.Create()
at SoftPro.Documents.Rendering.TextControl.TXTextRendererImpl.SoftPro.Documents.Client.Rendering.IRendererImpl.Render(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IRenderable renderable, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.InternalRender(IDocumentInfo document, Object context, IPrompt`1 prompt, IProgress`1 progress, CancellationToken cancellationToken)
at SoftPro.Documents.Client.Rendering.Renderer.Render(IDocumentInfo document, Object context, IPrompt`1 prompt)
at WorkBenchLibrary.Utilities.SoftProCommands.PrintDocument(String documentName, Object context, PrinterSettings printerSettings) in C:\TFS\PGPTitle\SoftPro Shell Packages\EditorFactory\WorkBench\Utilities\SoftProCommands.cs:line 150