Export MS Word Document pages to Images -
i want export ms word(docx/doc) document pages image(jpeg/png).
i doing same presentation(pptx/ppt) using office interop export api each slide, didn't found corresponding api word.
need suggestion api/alternate approach achieving this.
based on similar question: "saving word document image" this:
const string basepath = @"c:\users\someuser\somepath\"; var docpath = path.combine(basepath, "documenta.docx"); var app = new application() { visible = true }; var doc = app.documents.open(docpath); foreach (window window in doc.windows) { foreach (pane pane in window.panes) { (var = 1; <= pane.pages.count; i++) { var page = pane.pages[i]; var bits = page.enhmetafilebits; var target = path.combine(basepath, string.format("page-no-{0}", i)); using (var ms = new memorystream(bits)) { var image = image.fromstream(ms); var pngtarget = path.changeextension(target, "png"); image.save(pngtarget, imageformat.png); } } } } app.quit();
basically, i'm using page.ehmmetafilebits
property which, according documentation:
returns object represents picture representation of how page of text appears.
... , based on that, create image , save disk.
Comments
Post a Comment