I wish to preview a component presentation and get the rendered content from within another Component Template. I can call engine.RenderComponentPresentation() to get the rendered content, however I want to do this in preview mode, to avoid that Tridion then thinks that this CP is part of the page, and to have the image paths absolute and resolvable (I am generating a PDF in my TBB from the previewed CP). Is there another way to preview a Component Presentation/Component/Component Template using the TOM.NET API (the GUI does it so I guess it must somehow be possible)?


This can be done (as suggested) by using the RenderEngine.Render method. The trick is to ensure you read the RenderedItem.Content stream correctly:

var pi = new PublishInstruction(m_Engine.GetSession());
pi.RenderInstruction = new RenderInstruction(m_Engine.GetSession()) { RenderMode = RenderMode.PreviewStatic };
var stream = RenderEngine.Render(component, template, pi, null).Content;
stream.Seek(0L, SeekOrigin.Begin);
var html = new StreamReader(stream).ReadToEnd();

2 Answers 2


You can use Render method on RenderEngine:


Here's the signature:

public static RenderedItem Render(
                                    IdentifiableObject item,
                                    Template template,
                                    PublishInstruction instruction,
                                    PublicationTarget target

In your PublishInstruction you can set RenderMode to preview:

        var pi = new PublishInstruction();
        pi.RenderInstruction = new RenderInstruction(session) { RenderMode = RenderMode.PreviewStatic};
  • Aha... Thanks - looks like just what I need, but I can't quite get it to work (see update in question)
    – Will Price
    Commented Aug 22, 2013 at 14:54
  • The stream you have is already read, so you need to set position back to 0: renderedCP.Content.Position = 0; before initiating stramreader Commented Aug 22, 2013 at 19:26
  • Thanks - I had just worked that out for myself too! Question updated with a working code example
    – Will Price
    Commented Aug 22, 2013 at 20:57

The preview does an Http call to the Rendering.svc WCF service.


You can try calling that service again, by passing the JSON parameters in the Request content.


If you want to call internal services you have to provide the following header.

X-SDL-Tridion-Token: [some numeric value]
  • 4
    And let's not forget that this is not a public API Commented Aug 22, 2013 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.