Compress the file size of all images within a document

W

Wowbies

I am (opining/repairing/archiving) a large number of documents (RTF). I need
to be able to make the files as small as possible without losing the images
completely. Also, any ideas on how to remove the extraneous formatting
information that is saved within the RTF file would be helpful as well.

This is what I have so far:

public static void Fix( string fileIn, string fileOut)
{

//Open File Info
object _FileNameOpen = fileIn;
object _ReadOnly = false;
object _isVisible = false;
object _OpenAndRepair = true;
object _missing = System.Reflection.Missing.Value;

//Save File Info
object _FileName = fileOut;
object _FileFormat = WdSaveFormat.wdFormatRTF;
object _LockComments = false;
object _Password = _missing;
object _AddToRecentFiles = false;
object _WritePassword = S_missing;
object _ReadOnlyRecommended = false;
object _EmbedTrueTypeFonts = false;
object _SaveNativePictureFormat = true;
object _SaveFormsData = false;
object _SaveAsAOCELetter = false;
object _Encoding = _missing;
object _InsertLineBreaks = _missing;
object _AllowSubstitutions = true;
object _LineEnding = _missing;
object _AddBiDiMarks = false;


Microsoft.Office.Interop.Word.Application objWord = new
Microsoft.Office.Interop.Word.Application();

//open the file internally in word.
objWord.Documents.Open(
ref _FileNameOpen,
ref _ReadOnly,
ref _missing,
ref _missing,
ref _missing,
ref _missing,
ref _missing,
ref _missing,
ref _missing,
ref _missing,
ref _isVisible,
ref _missing,
ref _OpenAndRepair,
ref _missing,
ref _missing,
ref _missing);

//Do the background activity

objWord.Visible = false;

Microsoft.Office.Interop.Word.Document oDoc =
objWord.ActiveDocument;

foreach( InlineShape objPic in oDoc.InlineShapes)
{
objPic = objPic; //This is where I would like to compress
the image definintion if possible
}




oDoc.SaveAs(
ref _FileName,
ref _FileFormat,
ref _LockComments,
ref _Password,
ref _AddToRecentFiles,
ref _WritePassword,
ref _ReadOnlyRecommended,
ref _EmbedTrueTypeFonts,
ref _SaveNativePictureFormat,
ref _SaveFormsData,
ref _SaveAsAOCELetter,
ref _Encoding,
ref _InsertLineBreaks,
ref _AllowSubstitutions,
ref _LineEnding,
ref _AddBiDiMarks
);



//Close/quit word

objWord.Quit(ref _missing, ref _missing, ref _missing);
}
 

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