Table of Contents

Method SetImageCrop

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

SetImageCrop(WordDocument, ImageRef, int, int, int, int)

Crops a picture: how much of its source is cut from each side, as Word's Crop tool does.

public static DocumentEdit SetImageCrop(this WordDocument document, ImageRef image, int left, int top, int right, int bottom)

Parameters

document WordDocument

The document that holds the picture.

image ImageRef

The picture.

left int

The crop from the left, in thousandths of a percent of the source's width (100000 is all of it).

top int

The crop from the top, in thousandths of a percent of the source's height.

right int

The crop from the right.

bottom int

The crop from the bottom.

Returns

DocumentEdit

The edit; Before is just before the picture and After just past it. The values the picture already has give an empty edit.

Remarks

The picture keeps its scale, as in Word: what is left of the source is shown at the size it had, so the picture gets smaller by what was cut and larger by what was restored. ResizeImage(WordDocument, ImageRef, Emu, Emu) afterwards gives it another size.

Exceptions

ArgumentNullException

document or image is null.

ArgumentException

The picture is not in document, or not in a paragraph.

ArgumentOutOfRangeException

A crop is negative, the left and right or the top and bottom together leave nothing of the source, or the picture would be wider or taller than MaxImageSide.

InvalidOperationException

The picture's drawing is not one DrawingML picture, or it is in a shape's text box.