Home > Net >  About the Microsoft c # applications. Office. Interop. Word, read the Word document images
About the Microsoft c # applications. Office. Interop. Word, read the Word document images

Time:11-21

1, in the hope that the functions, read out all images from the word document and save into image files,
2, the code a lot, to find a can be stored,
//picture 
Int imgCount=0;
Foreach (Word. Com.lowagie.text.paragraph com.lowagie.text.paragraph in doc. Paragraphs)
{
If (com.lowagie.text.paragraph!=null)
{
If (com.lowagie.text.paragraph. Range. The Text. The Trim ()!="")
{
If (com.lowagie.text.paragraph. Range. InlineShapes Count!=0)
{
Foreach (Word. InlineShape shape in com.lowagie.text.paragraph. Range. InlineShapes)
{
//string TXT="";
If (shape. Type==Word. WdInlineShapeType. WdInlineShapePicture)
{
//use the clipboard data
Shape. The Select ();//the current selected image
Doc. ActiveWindow. Selection. The Copy ();//copy of the current picture
//the string fileName="";
If (Clipboard. ContainsImage ())
{
ImgCount++;
Bitmap BMP=new Bitmap (Clipboard. The GetImage ());
//BMP. Height
String imgName=fileName + "_img_" + imgCount. ToString () + ". JPG ";
BMP. Save (imgName, System. Drawing. Imaging. ImageFormat. Jpeg);
}
}
If (shape. Type==Word. WdInlineShapeType. WdInlineShapeChart)
{
//TXT +=shape. The ToString ();
}
}
}
}
}
}

3, actually already took a photo storage,

Problem: this approach to store the image file is compressed,
Below are the files: the resolution is 553 * 311


But in fact the original resolution of the image is 1267 * 713


The resolution is 1267 * 713 images there are two access to
A, save as word file. The HTM file, in the files in the file you can see the original image and uncompressed image

B, word documents directly through open winrar, in a word/media folder as you can see the original


with how to take out the original code, I don't want a thumbnail, strives for the great god give directions, thank you,
  •  Tags:  
  • C#
  • Related