We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add Background Color to PDF Page using Aspose.PDF for .NET

I am trying to get my background color Red to show up against my transparent tiff image. It is not working. Pls let me know asap.

Dim imgBack1 As New Aspose.Pdf.Image(sec2)
imgBack1.ImageInfo.File = backGroundBackURL 'Server.MapPath(backGroundBackURL)
imgBack1.ImageInfo.ImageFileType = Aspose.Pdf.ImageFileType.Tiff

sec2.Paragraphs.Add(imgBack1)

sec2.BackgroundColor = New Aspose.Pdf.Color(sHexColor)

Hi,

Thanks for considering Aspose.

I've tested the scenario with one of my sample TIFF file and I am able to see both Image and BackGround color in my case. Please share the TIFF image that you are using, so that we can test the issue using that file.

Can you please copy paste your code here?

Thanks,

Shr

Hi,

Here is the code I used and the resultant pdf file is attached:

[C#]

Pdf pdf1 = new Pdf();
Aspose.Pdf.Section sec = pdf1.Sections.Add();
Aspose.Pdf.Image img = new Aspose.Pdf.Image(sec);
img.ImageInfo.File = @"E:/temp/calendar_transparent_300dpi.tif";
img.ImageInfo.ImageFileType = ImageFileType.Tiff;
sec.Paragraphs.Add(img);
sec.BackgroundColor = new Aspose.Pdf.Color("Red");
pdf1.Save("E:/temp/test.pdf");

It is the same as your code. I wonder if the resultant pdf is what you expected. Please try it and be free to ask further questions.

Best regards.

the resultant pdf is not giving me the bacground color. Please let em know why that would be.

can you also upload the tiff file you created so i can see the background color with this image? i noticed the pdf test.pdf you created and I cannot see the red color bleow the calendar image. i can see red all around it but since calendar is transparent, I want to see the red color under the image itself.

Thanks,

Hi,

Thanks for considering Aspose.

You can access the TIFF file attached with in this forum thread. Regarding your requirement "background color Red to show up against my transparent tiff image", we are looking into this matter and will reply to you soon.

Hi,

I will wait to get the solution to have the background color show up on the transparent tiff.

Thanks,

Hi,

Please try the following code to set the image’s opacity:

[C#]

Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();
Aspose.Pdf.Section sec = pdf1.Sections.Add();
Aspose.Pdf.Image img = new Aspose.Pdf.Image(sec);
img.Opacity = 0.8F;
// Gets or sets a float value between 0.0 and 1.0 that indicates the opacity of the image. The default value is 1.0.
img.ImageInfo.File = @"E:/temp/calendar_transparent_300dpi.tif";
img.ImageInfo.ImageFileType = ImageFileType.Tiff;
sec.Paragraphs.Add(img);
sec.BackgroundColor = new Aspose.Pdf.Color("Red");
pdf1.Save("E:/temp/test.pdf");

The resultant pdf is attached. Thanks.

Best regards.

we dont want the opacity - we want the transparent tiff to have the background red -if you noticed in yoru pdf, the background color is pinkish and not red. we want the background color red to show alongwith the image on top of it.

Hi,

At present, we support transparent background for some image types(like Gif, Png, etc). I am not sure if the tiff image is transparent. As I can’t get the result as you expected in MS Word(see the attached doc). Please correct me if I miss something. Thanks.

Best regards.