News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Diagram Preview

Started by Nikolay, September 09, 2010, 06:04:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

How do I generate a small diagram "preview" (thumbnail) picture programmatically (you can see those in explorer, for example)?
Supposing I have either a Visio file on disk, or a Visio Document object (not sure which one might be a better starting point)

I can see following options:
- Grab thumbnail data from explorer using some shell api (which one?)
- Export drawing to some manageable vector format, then resize (which format? wmf/emf? how to preserve background?)

As a result, I want a fixed-size bitmap (say, 64x64)
Thanks in advance!

Jumpy

Check out
ActiveDocument.PreviewPicture
in the help.

I don't understand everything they say there, but it seems to be sth. with emf file.
Maybe you can make more sense of what is said there.



Nikolay

Thanks! I'll definitely give it a try.

aledlund

I use something like this in my vba code

docCopy.SavePreviewMode = visSavePreviewDraft1st
docCopy.SaveAsEx strCopy, visSaveAsWS
DoEvents
docCopy.Close
DoEvents

al

Nikolay

Thanks al, but doesn't this code save document with preview picture?
I don't actually need to save document with preview picture; I need the document preview picture itself ;)

It seems that Document.PreviewPicture did the trick pretty well, and the only thing left to me were the boring technical details:

IPicture pic = (IPicture)doc.PreviewPicture;
Image img = new Metafile((IntPtr)pic.Handle, true);

JuneTheSecond

Cool!
Your solution is valuable to me, too.
Thank you.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

aledlund

sorry about that! I obviously misunderstood what you were attempting to do  :(
al

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 261 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1122KB.
Tokens: post-login.
Cache hits: 13: 0.00161s for 26,767 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]