I need to generate a preview thumbnail image of a RadDocument. Unfortunately I cannot get it to work:
DocumentViewManager viewManager = new DocumentViewManager();
XamlFormatProvider xamlProvider = new XamlFormatProvider();
viewManager.Document = xamlProvider.Import(xamlProvider.Export(VM.Document));
viewManager.Document.LayoutMode = DocumentLayoutMode.Paged;
RadRichTextPageView view = new RadRichTextPageView();
view.PageIndex = 0;
ScaleTransform transform = new ScaleTransform();
transform.ScaleX = 0.4;
transform.ScaleY = 0.4;
view.RenderTransform = transform;
view.ViewManager = viewManager;
view.PageIndex = 0;
var writeableBitmap = new WriteableBitmap(200, 200);
view.InvalidateMeasure();
writeableBitmap.Render(Editor, null);
writeableBitmap.Invalidate();
var image = new Image();
image.Width = 200;
image.Height = 200;
image.Source = writeableBitmap;
var wnd = new ChildWindow();
wnd.Content = image;
wnd.Show();
Any suggestions?
DocumentViewManager viewManager = new DocumentViewManager();
XamlFormatProvider xamlProvider = new XamlFormatProvider();
viewManager.Document = xamlProvider.Import(xamlProvider.Export(VM.Document));
viewManager.Document.LayoutMode = DocumentLayoutMode.Paged;
RadRichTextPageView view = new RadRichTextPageView();
view.PageIndex = 0;
ScaleTransform transform = new ScaleTransform();
transform.ScaleX = 0.4;
transform.ScaleY = 0.4;
view.RenderTransform = transform;
view.ViewManager = viewManager;
view.PageIndex = 0;
var writeableBitmap = new WriteableBitmap(200, 200);
view.InvalidateMeasure();
writeableBitmap.Render(Editor, null);
writeableBitmap.Invalidate();
var image = new Image();
image.Width = 200;
image.Height = 200;
image.Source = writeableBitmap;
var wnd = new ChildWindow();
wnd.Content = image;
wnd.Show();
Any suggestions?
7 Answers, 1 is accepted
0
Hello Oliver,
For some reason, when capturing the RadRichTextPageView as a bitmap using WriteableBitmap, Silverlight doesn't render it correctly. We are making an effort to make it work, but we don't currently have a solution to the problem. What we recommend for now is to render the document dynamically using RadRichTextPageView. We are sorry for any inconvenience caused.
Kind regards,
Ivailo
the Telerik team
For some reason, when capturing the RadRichTextPageView as a bitmap using WriteableBitmap, Silverlight doesn't render it correctly. We are making an effort to make it work, but we don't currently have a solution to the problem. What we recommend for now is to render the document dynamically using RadRichTextPageView. We are sorry for any inconvenience caused.
Kind regards,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Oliver
Top achievements
Rank 1
answered on 13 Apr 2011, 11:59 AM
Ivailo, thanks for the update. What do you mean with "render the document dynamically"?
0
Hi Oliver,
I'm sorry I didn't make myself clear. What I meant was, that I recommend you to put a RadRichTextPageView with the document page you want to show (render the document dynamically, instead of statically, e.g. from a pre-rendered bitmap). This will carry a performance penalty, as RadRichTextPageView is much slower than rendering a simple bitmap, but we haven't found a viable solution yet.
All the best,
Ivailo
the Telerik team
I'm sorry I didn't make myself clear. What I meant was, that I recommend you to put a RadRichTextPageView with the document page you want to show (render the document dynamically, instead of statically, e.g. from a pre-rendered bitmap). This will carry a performance penalty, as RadRichTextPageView is much slower than rendering a simple bitmap, but we haven't found a viable solution yet.
All the best,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Oliver
Top achievements
Rank 1
answered on 15 Apr 2011, 08:24 AM
I think this is a misunderstanding. My sample code only used the ChildWindow for showcasing the effect. The desired use is to render the thumbnail and store somewhere as JPG.
0
Hi Oliver,
Rendering the document on an image using WriteableBitmap produces artifacts. We currently don't know of a way to render the document to an image.
Greetings,
Ivailo
the Telerik team
Rendering the document on an image using WriteableBitmap produces artifacts. We currently don't know of a way to render the document to an image.
Greetings,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Oliver
Top achievements
Rank 1
answered on 15 Apr 2011, 10:18 AM
Yes I've understood that but your last comment sounded a bit like as if you were trying to offer a workaround (which I didn't get by the way :)
One question though, until now I haven't found a single control that refused to render to a WriteableBitmap. How comes the RadRichTextBox is so different?
One question though, until now I haven't found a single control that refused to render to a WriteableBitmap. How comes the RadRichTextBox is so different?
0
Hi Oliver,
Actually, if the RadRichTextPageView is already present in the visual tree and shown on the screen, taking a snapshot of it works correctly. If it is not, however, the text inside it gets overlapped, which is obviously undesired. Unfortunately, adding it to the visual tree on-the-fly doesn't help. We're not sure exactly why Silverlight fails to render it correctly if it hasn't been show previously and thus, we're unable to fix the issue.
Greetings,
Ivailo
the Telerik team
Actually, if the RadRichTextPageView is already present in the visual tree and shown on the screen, taking a snapshot of it works correctly. If it is not, however, the text inside it gets overlapped, which is obviously undesired. Unfortunately, adding it to the visual tree on-the-fly doesn't help. We're not sure exactly why Silverlight fails to render it correctly if it hasn't been show previously and thus, we're unable to fix the issue.
Greetings,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items