Cut the content of an Aspose.Words.document

How could I do it?
Thanx
Yohann

Please provide a more specific task description.
Best regards,

I’d like to do like with Word.Document :

Word.Document innerDocument = null;
innerDocument.Content.Cut();

Is it possible to do it with an Aspose.Words.Document?
Thank you
Yohann

If you want to cut the content of the document for the purpose of subsequent copying it to the other document, then it is done differently in Aspose.Words. Check Insert One Document into Another at Any Location article in documentation.
If you want just clearing the content of the document, then it is easier to just initialize a new instance of the document:

doc = new Document();

Hope this helps,

Thanks.
And is it possible to copy the document in memory like when we copy text with the mouse and we paste it next?

No, it is not possible in the meaning that you put to it.

Right thanks.
I have another problem
Do you know how to resize a picture before insert it in the document.
I used that but it cuts my picture and not resize it :
---------------------------------------------------------------------------------------

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertImage("MyImage.jpg", RelativeHorizontalPosition.Margin, 100,

RelativeVerticalPosition.Margin, 100, 200, 100, WrapType.Square);

---------------------------------------------------------------------------------------

Thank you
Yohann

Strange, in all of my tests the image is scaled correctly. I have also tried your code and again, the image was scaled correctly when I have tested it.

Maybe there is a problem in my document. I’m going to try again with a blank document and just one picture.
In each document that I product, I have to insert a picture or more in a specific place. This place has a size which never change.
Do you know if there is something to resize the picture automatically according to the size of the place in my document?
Thank you miklovan

Sorry, I have not had enough time to write the code example today. I will write it tomorrow. Here are some tips though. DocumentBuilder.InsertImage returns a Shape object that you can manipulate afterwards. You can reposition and resize it, and even set another image to it. You can use textbox with a bookmark inside to create named fixed size places in the document to place image to. Bookmark nodes can be used to reposition the DocumentBuilder. Then you can insert image, get the Shape object, find its textbox container using GetAncestor method, take its size parameters and apply them to the shape object. Or, even better, you can first find the size of the textbox containing a bookmark and then use this size as to set parameters in InsertImage.
Hopes this makes sense,

I’ll try what you told me but I found something.
I got the height of the cell using
builder.RowFormat.Height but it will only work
if RowFormat.HeightRule == HeightRule.Explicit.
So if RowFormat.HeightRule == HeightRule.Explicit it’s OK it works very well but when RowFormat.HeightRule != HeightRule.Explicit I can’t get the height of the cell

My code is :


double d = this.innerDocumentBuilder.CellFormat.Width;
double h = 0.0;
Image image = Image.FromFile(fichierPhoto);
if (this.innerDocumentBuilder.RowFormat.HeightRule == HeightRule.Exactly)
{
    h = this.innerDocumentBuilder.RowFormat.Height;
    Size grap = new Size((int)d, (int)h);
    Size final = new Size((int)image.Width, (int)image.Height);
    final = TraitementPhoto.ReSize(grap, final);
    this.innerDocumentBuilder.InsertImage(fichierPhoto, Aspose.Words.Drawing.RelativeHorizontalPosition.Margin, 100, Aspose.Words.Drawing.RelativeVerticalPosition.Margin, final.Height, final.Width, final.Height, Aspose.Words.Drawing.WrapType.Inline);
}
else
{
    // I don’t know how to get the height of the cell
}

Yes, you need to set an explicit height for the rows with table cells that you want to insert images in.
Rows which don’t have explicit height can change the height according to content and therefore their height is not stored in the document
To set explicit height in your template use MS Word 2003 Table properties | Row | Row height is: Exactly setting .
Hope this helps,

Thanks miklovan for your help.
I’m new and I try to use Aspose and all its possiblities.
Like my resizing problem is resolve, I’d like to show you another thing that I can’t resolved too
My problem : I create an Aspose.Words.Document with bookmarks and their values(text and pictures), text… and I save it in a ms word document(".doc"). It works and I’m glad. But now I’d like to open it with the “viewer demo” of Aspose.Words or with the “editor demo” of Aspose.Editor. I can open it but the result is not very good :
- Viewer Demo : Not very beautiful and a lot of mistakes in the disposition.
- Editor Demo : Pictures doesn’t work, text yes but when there is something next to the first picture this is not displayed.
Could you tell me why this is not working please?
Thanks for your fast and good answers
Yohann

Ps : I can send you the screenshots of my document with the viewer demo, editor demo and ms word.

Viewer is our first try of rendering implementation, very raw and immature. We are now working on a new rendering engine and hopefully will release it later this year. Aspose.Editor in its current state is also having a number of limitations but it is constantly evolving and will definitely become better in a short time.
So we definitely cannot compete with word in WYSIWYG now but sometime we will :slight_smile: