Sign In  Sign Up Live-Chat

Document back color

Last post 10-15-2008, 4:13 AM by alexey.noskov. 6 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
     
  •  09-02-2008, 9:21 AM 142020 in reply to 134365

    Re: Document back color

    Hi Alexey,

    Can you estimate when the direct method of setting the page color shall be supported ?

    Thanks,
    Milan
     
  •  09-02-2008, 9:45 AM 142028 in reply to 142020

    Re: Document back color

    Hi

     

    Thanks for your inquiry. This is issue #3911 in our defect database. Unfortunately currently I can’t provide you any estimate.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  10-15-2008, 2:59 AM 147989 in reply to 142028

    Re: Document back color

    Hi Alexey,

    Just a small add on this issue, no need to reply on.
    By "setting page color support" I didn't want to refer on the possibility of setting color for every single page. I wanted to refer on setting a background color for the entire document.

    Regards,
    Milan
     
  •  10-15-2008, 4:13 AM 148001 in reply to 147989

    Re: Document back color

    Hi

     

    Thanks for your request. Yes, issue #3911 means exactly what you need – setting background color of entire document.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML