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)?
UPDATE:
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();