Control of api-driven JPEG export?

D

Don

Hi, folks --

I've been tasked to write some simple JPEG/EMF export apps to interface
with an enterprise content management system. The ECM triggers one or more
of these little helpers when a content item of the corresponding type is
checked in, and the helper spits out a JPEG or EMF of the correct size, dpi,
compression, and so on, or it spits out an EMF.

Here's the code I'm currently using to drive Visio to spit out a JPEG:

Private Function ExportDrawing( _

byRef strDrawingName as String, _

byRef strExportFile as String _

) as Boolean



Dim objVisioApp As New Visio.InvisibleApp


Dim objVisioDoc As Visio.Document

Dim objVisioPage As Visio.Page





objVisioDoc = objVisioApp.Documents.Open( strDrawingName )

objVisioPage = objVisioDoc.Pages( 1 )



objVisioPage.CenterDrawing

objVisioPage.Export( strExportFile )



objVisioDoc.Saved = True ' avoid "exit without saving" dialog box.

objVisioApp.Quit



ExportDrawing = True



End function

(Actually, it'll spit out any format, as long as the destination file's
extension is supported.)

No-nonsense: no smart error-trapping yet, and it doesn't try to connect to
a running Visio session. But it works. Almost.

Before polishing it, I need to find a way to control the JPEG compression,
dpi, and so on. I haven't been able to find out how to do this via the Visio
API. This is surprising considering how much more control I had over this in
the other Office apps. Perhaps I'm just not looking in the right place.

Do you know how to control export image resolution in Visio? Or do you
know of a good "batch" Visio-to-JPEG converter app someplace?
 
D

David Parker

I think that the Export uses the last manually set configuration...
So, do it once manually, just before you run the automation...
 
D

Don

Hi, David --

Thanks for taking the time to reply to my question!

I wasn't successful at controlling the paramters of a JPEG export from a
run of my compiled VB code by first exporting a drawing interactively from
Visio, probably because my VB code currently does a ...

Dim objVisioApp As New Visio.InvisibleApp


.... each run. Perhaps if it connected to a running session instead of
creating a new one each time, and perhaps if the session were a
Visio.Application rather than a Visio.InvisibleApp, this trick would have
worked.

But no matter what, it really doesn't sound like there is an exposed API
JPEG export method which takes resolution & compression arguments.

If anybody does stumble across such a method, or a third-party app that
can take a .vsd file & generate JPEGs of any specific resolution & size,
please post a reply here!

Thanks & have a great day!

Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top