Sign In  Sign Up Live-Chat

Document back color

Last post 07-08-2008, 1:41 AM by abdalimohd123. 2 replies.
Sort Posts: Previous Next
  •  07-04-2008, 7:01 AM 134351

    Document back color

    Hi,

    Please provide a sample code for setting up back color for the document. I saw code to set up the same for cells. But need to set up for the whole document.

    Thank you,

    Ali

     

     
  •  07-04-2008, 8:36 AM 134365 in reply to 134351

    Re: Document back color

    Hi

     

    Thanks for your inquiry. Unfortunately there is no direct method to set background color of the whole document. But I think that you can use the following code as a workaround.

     

    Document doc = new Document();

    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

    Shape background = new Shape(doc, ShapeType.Rectangle);

    background.Width = builder.CurrentSection.PageSetup.PageWidth;

    background.Height = builder.CurrentSection.PageSetup.PageHeight;

    background.BehindText = true;

    background.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;

    background.RelativeVerticalPosition = RelativeVerticalPosition.Page;

    background.VerticalAlignment = VerticalAlignment.Center;

    background.HorizontalAlignment = HorizontalAlignment.Center;

    background.FillColor = Color.Red;

    builder.CurrentParagraph.AppendChild(background);

    doc.Save(@"Test274\out.doc");

     

    This code inserts filled rectangle behind document content.

     

    Hope this helps.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  07-08-2008, 1:41 AM 134643 in reply to 134365

    Re: Document back color

    thank you alexey. that works
     
View as RSS news feed in XML