We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DocIO TextBox: set background to transparent

I'm trying to add a TextBox to a Word document, and set the background to transparent / no fill colour. However, this does not seem to work: background is always white.

The code to set the FillColor works when setting it to any other colour (eg: yellow), but not when setting it to Transparent, or to any colour with alpha level 0 (= no opacity):

textbox.TextBoxFormat.NoLine = true;
textbox.TextBoxFormat.FillEfects.Color = System.Drawing.Color.Transparent;


I've also tried with this code, but the problem persists:

textbox.TextBoxFormat.NoLine = true;
textbox.TextBoxFormat.FillEfects.Type = BackgroundType.NoBackground;
textbox.TextBoxFormat.FillColor = System.Drawing.Color.Transparent;
textbox.TextBoxFormat.FillEfects.Color = System.Drawing.Color.Transparent;


Any ideas on how to solve this? The textboxes are laying on top of an image and are the frontpage of a report we're generating, so it's essential they've got a transparent background.


9 Replies

PR Poornima R Syncfusion Team January 17, 2011 07:05 AM UTC

Hi Kevin,

Thank you for your interest in Syncfusion Products.

For your requirement of displaying transparency effect for the text box above the picture, could you please try the below code snippet and let us know if this helps you.

Code Snippet:

textBox.TextBoxFormat.FillColor = Color.Transparent;
textBox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;


Please let us know if you have any queries.

Regards,
Poornima




KD Kevin Dockx January 17, 2011 09:07 AM UTC

Hello,

thanks for the reply. However, the same problem persists - the fillcolour of the textbox seems to be white, not transparent.



KD Kevin Dockx January 17, 2011 03:50 PM UTC

Update: we solved the problem by adding the textboxes to the template, formatting them so the background is transparent, and accessing them as such. Formatting them from code doesn't seem to work...



PR Poornima R Syncfusion Team January 18, 2011 12:28 PM UTC

Hi Kevin,

Thank you for your update

We were able to reproduce the mentioned issue with "Transparancy effect of textbox". We suspect this could be a defect. We have forwarded this issue to our development team for further analysis.

Could you please report this issue through Direct Trac Developer Support System
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well. If you have already reported, please ignore this.

Please let me know if you have any questions.

Regards,
Poornima




PR Poornima R Syncfusion Team January 18, 2011 01:21 PM UTC

Hi Kevin,

Thank you for your update

We were able to reproduce the mentioned issue with "Setting Transparancy effect for textbox". We suspect this could be a defect. We have forwarded this issue to our development team for further analysis.

Could you please report this issue through Direct Trac Developer Support System
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well. If you have already reported, please ignore this.

Please let me know if you have any questions.

Regards,
Poornima




SU Sudhanva February 22, 2012 09:16 AM UTC

Hello,

I am using syncfusion ver 9.4.I want to allign the text to center
inside the TextBox.can you please provide me a sample code to align text to center

Code:
IWTextBox Address = footerPar.AppendTextBox(210, 60);
Address.TextBoxFormat.LineColor = System.Drawing.Color.White;


Address.TextBoxBody.AddParagraph().AppendText(cmpaddrtxt.Text);



PR Poornima R Syncfusion Team February 23, 2012 04:17 AM UTC

Hi Sudhan,

Thank you for your update.

Regarding your requirement of “Preserving center alignment for the text within the textbox”, please try setting the horizontal alignment for the paragraph within the text box as in the below code snippet. Please try using the below code snippet and let us know if this meets your requirement.

Code snippet:

IWTextBox Address = footerPar.AppendTextBox(210, 60);
Address.TextBoxFormat.LineColor = System.Drawing.Color.White;
IWParagraph paragraph = Address.TextBoxBody.AddParagraph();
paragraph.AppendText(cmpaddrtxt.Text);
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;


Please let us know if you have any questions.

Regards,
Poornima




DB Danielle BOURGADE October 26, 2023 02:55 PM UTC

Hi,

I am using de version 19.4.053 of Syncfusion.DocIO and the problem seem persists. The textbox fill color is not transparent but white.

What news ?

Thanks



AA Akash Arul Syncfusion Team November 14, 2023 02:04 PM UTC

Hi Danielle,

Currently, DocIO library doesn’t support transparency in textbox fill color. We have already logged this as a feature request in our database. We don’t have any immediate plans to implement this feature. We will let you know when this feature is implemented.

As a workaround, kindly use Shape instead of Textbox in your Word document. Because transparency is supported in Shape in DocIO.

Please refer to the below UG documentation to know more about working with shapes.
Working with shapes

Please refer to the below code snippet to set transparency for a shape in a Word document.

            WordDocument document = new WordDocument();

            document.EnsureMinimal();

            //Append shape to the document.

            Shape shape = document.LastParagraph.AppendShape(AutoShapeType.Rectangle, 100, 100);

            //Set fill color for the shape.

            shape.FillFormat.Color = System.Drawing.Color.Red;

            //Set transparency for the shape.

            shape.FillFormat.Transparency = 50;

            //Save and close the document.

            document.Save(@"../../Output.docx", Syncfusion.DocIO.FormatType.Docx);

            document.Close();


Regards,
Akash.


Loader.
Live Chat Icon For mobile
Up arrow icon