Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Aug 05, 2016 11:40 am

Hi Betsy,

On your uploaded PDF file I can only see w white background?

I have set the BackgroudOpacity to 0.8f, but this does 2 things:
1. It makes the background image clearer (less faded) and close to the original, which is good.
2. Sadly the 0.8f Opacity also makes the orginal text on the PDF file less clearer.

It seems that the 0.8f opacity for the background image makes the text on the original PDF file (where the image is attached to) 0.2f, and vice versa, when I adjust the backgroudopacity to 0.2f it seems that it makes the original text opacity 0.8f..

To let you show the results:

I have used your attached PDF example as the original PDF file (posted as print screen now):
Image



Then I have the following jpg background image that I want to attach as background on the original PDF:
Image

I am using the following bit of code to attach the background image to your PDF file:

Code: Select all
PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(OriginalPDFDocumentPath);
            foreach (PdfPageBase page in doc.Pages)
            {
                page.BackgroundImage = Image.FromFile(BackgroundImagePath);
                page.BackgroudOpacity = 0.8f;
            }
            string output = "result.pdf";
            doc.SaveToFile(SavePDFAsAndToLocationPath);


Where the OriginalPDFDocumentPath is the path to your PDF file, BackgroundImagePath is the path to the background jpg and the SavePDFAsAndToLocationPath is the file path where I am saving the combined PDF to.

With using 0.8f as opacity I get this result:

Image

As you can see, the background image (don't mind the stretching of the image) is nearly the same (color wise) but the original PDF text get's faded (the opacity of the text seems to get less).

NicolasMous
 
Posts: 6
Joined: Fri Jun 17, 2016 1:43 pm

Mon Aug 08, 2016 7:43 am

Dear NicolasMous,

Thanks for your feedback.
We will investigate this issue further, and then update to you.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Tue Aug 09, 2016 8:16 am

Dear NicolasMous,

After investigation, we found there is the method can acheive your target.
Code for your reference.
Code: Select all
            foreach (PdfPageBase page in doc.Pages)
            {
                //set this value as -1
                page.DefaultLayerIndex = -1;
                page.BackgroundImage = Image.FromFile(FilePath + "VSS_Layout_NL_ENG_NET.jpg");
                page.BackgroudOpacity = 1f;
            }

If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Tue Aug 30, 2016 2:28 pm

Hi Betsy,

Thanks for the help! Sadly I get an Out of Range Exception error when doing this:

Image

NicolasMous
 
Posts: 6
Joined: Fri Jun 17, 2016 1:43 pm

Wed Aug 31, 2016 1:59 am

Dear NicolasMous,

Thank for your feedback.
Sorry to hear that, but I didn't encounter that issue. Please try to use the latest Spire.PDF Pack(Hot Fix) Version:3.7.198. After trying this version, if the issue still persists, please provide us the sample document which encounter the issue to help us do an investigation.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Sep 02, 2016 8:32 am

Dear NicolasMous,

How is the issue now ?
Could you please give us some feedback at your convenience ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Sep 02, 2016 1:06 pm

Yes it works perfectly now! Had version 3.2 installed, with version 3.7 it seems to work!

Thank you for the great help!

NicolasMous
 
Posts: 6
Joined: Fri Jun 17, 2016 1:43 pm

Mon Sep 05, 2016 1:35 am

Dear NicolasMous,

Thanks for your feedback.
Please feel free to contact us if there is any needs or question.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Mon Apr 29, 2019 1:22 pm

Excellent work of the Spire team, I have had this problem and I have followed these steps and I have solved, I am glad to know that they give such good support to the clients and that until they do not achieve the solution they do not abandon them.

rdelacruz
 
Posts: 1
Joined: Mon Apr 29, 2019 1:07 pm

Tue Apr 30, 2019 1:44 am

Hello Rdelacruz,

Thanks for your good evaluation of our support. Just feel free to contact us if you have any question related to our products in the future. We are always here to help.
Have a nice day!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF