Cut the content of an Aspose.Words.document

Last post 04-19-2007, 10:28 AM by miklovan. 13 replies.
Sort Posts: Previous Next
  •  04-16-2007, 4:12 AM 73234

    Cut the content of an Aspose.Words.document

    How could I do it?
    Thanx
    Yohann
     
  •  04-16-2007, 5:57 AM 73247 in reply to 73234

    Re: Cut the content of an Aspose.Words.document

    Please provide a more specific task description.

    Best regards,


    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-16-2007, 6:41 AM 73251 in reply to 73247

    Re: Cut the content of an Aspose.Words.document

    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
     
  •  04-16-2007, 10:06 AM 73285 in reply to 73251

    Re: Cut the content of an Aspose.Words.document

    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,


    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-17-2007, 4:20 AM 73415 in reply to 73285

    Re: Cut the content of an Aspose.Words.document

    Thanks.
    And is it possible to copy the document in memory like when we copy text with the mouse and we paste it next?
     
  •  04-17-2007, 4:50 AM 73419 in reply to 73415

    Re: Cut the content of an Aspose.Words.document

    No, it is not possible in the meaning that you put to it.
    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-17-2007, 9:37 AM 73451 in reply to 73419

    Re: Cut the content of an Aspose.Words.document

    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
     
  •  04-17-2007, 11:37 PM 73516 in reply to 73451

    Re: Cut the content of an Aspose.Words.document

    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.

    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-18-2007, 2:15 AM 73533 in reply to 73516

    Re: Cut the content of an Aspose.Words.document

    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
     
  •  04-18-2007, 12:22 PM 73625 in reply to 73533

    Re: Cut the content of an Aspose.Words.document

    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,


    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-19-2007, 3:55 AM 73694 in reply to 73625

    Re: Cut the content of an Aspose.Words.document

    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
    }

    -------------------------------------------------------------------------------------------------------------------------------------------------------
     
  •  04-19-2007, 9:14 AM 73735 in reply to 73694

    Re: Cut the content of an Aspose.Words.document

    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,


    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
  •  04-19-2007, 9:46 AM 73738 in reply to 73735

    Re: Cut the content of an Aspose.Words.document

    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.
     
  •  04-19-2007, 10:28 AM 73744 in reply to 73738

    Re: Cut the content of an Aspose.Words.document

    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 :)


    Vladimir Averkin
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML