Hi
Thanks for your request. You can use code like the
following:
[Test]
public void Test001()
{
using (FileStream
imageStream = File.OpenRead(@"C:\Temp\in.tif"))
{
// Load the image into another document the images.
imageStream.Position = 0;
Document imageDoc = LoadImage(imageStream);
// Save document
imageDoc.Save(@"C:\temp\out.doc");
}
}
///
/// Loads
an image into Aspose.Words.Document object and rotates the image to 180
degrees.
///
/// Stream with an image.
public Document LoadImage(Stream
inputStream)
{
// Create Aspose.Words.Document and DocumentBuilder.
// The builder makes it simple to add content to the
document.
Document doc = new
Document();
DocumentBuilder builder = new
DocumentBuilder(doc);
// Read the image from file, ensure it is disposed.
using (Image image
= Image.FromStream(inputStream))
{
// Get the number of frames in the image.
int framesCount = image.GetFrameCount(FrameDimension.Page);
// Loop through all frames.
for (int frameIdx =
0; frameIdx < framesCount; frameIdx++)
{
// Insert a section break before each new page, in case of
a multi-frame TIFF.
if (frameIdx != 0)
builder.InsertBreak(BreakType.SectionBreakNewPage);
// Select active frame.
image.SelectActiveFrame(FrameDimension.Page,
frameIdx);
// We want the size of the page to be the same as the size
of the image.
// Convert pixels to points to size the page to the actual
image size.
PageSetup ps = builder.PageSetup;
ps.PageWidth = ConvertUtil.PixelToPoint(image.Width,
image.HorizontalResolution);
ps.PageHeight = ConvertUtil.PixelToPoint(image.Height,
image.VerticalResolution);
// Insert the image into the document and position it at
the top left corner of the page.
Shape shape = builder.InsertImage(
image,
RelativeHorizontalPosition.Page,
0,
RelativeVerticalPosition.Page,
0,
ps.PageWidth,
ps.PageHeight,
WrapType.None);
}
}
return doc;
}
Hope this helps.
Best regards,