Method SetImageCrop
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
documentWordDocumentThe document that holds the picture.
imageImageRefThe picture.
leftintThe crop from the left, in thousandths of a percent of the source's width (100000 is all of it).
topintThe crop from the top, in thousandths of a percent of the source's height.
rightintThe crop from the right.
bottomintThe 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
documentorimageis 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.