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 May 15, 2020 12:48 am

Hello .. Good night.
Is it possible with spire to modify the intensity of colors in an existing pdf file?
Something that made it possible to apply a degree of intensity.
Is there anything like that in the api?
Thanks in advance!

gafforelli
 
Posts: 37
Joined: Sat Sep 15, 2018 6:38 pm

Fri May 15, 2020 3:59 am

Hello,

Thanks for your inquiry.
Our product supports adding background color to existing PDF and setting its transparency to modify the color intensity. Please refer to the below sample code. If this is not what you want, please provide your test documents and your desired output to help further look into it. You can upload here or send them to us via email([email protected]).
Code: Select all
//load pdf
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("test.pdf");
//traverse all pages of the document
foreach (PdfPageBase page in pdf.Pages)
      {
       //set page background color
       page.BackgroundColor = Color.LightSkyBlue;
       page.BackgroudOpacity = 0.1f;
      }
//Save the document
 pdf.SaveToFile("result.pdf");

Sincerely,
Sara
E-iceblue support team
Last edited by Sara.Yang on Wed May 20, 2020 7:58 am, edited 1 time in total.
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Tue May 19, 2020 9:23 pm

Hello Sara, good night!
Thank you very much for the quick return.
In fact, what I need is to work on the transparency of the PDF, be it pdf image or pdf text.
Attached is an original file (original.pdf) and a modified file (Process.pdf) in Example.rar
Is it possible to do this type of manipulation with the API?
Thank you!

gafforelli
 
Posts: 37
Joined: Sat Sep 15, 2018 6:38 pm

Wed May 20, 2020 7:30 am

Hello,

Thanks for your requiry.
Sorry there is no direct way to work on the transparency of the PDF. However, your can refer to the following code to draw a template to achieve the effect. I attached my result document for your reference. If there is any question, please feel free to contact us.
Code: Select all
            //create a file and set its background
            PdfDocument doc1 = new PdfDocument();
            PdfPageBase page1 = doc1.Pages.Add(PdfPageSize.A4, new PdfMargins(0));
            page1.BackgroundColor = Color.LightGray;
            page1.BackgroudOpacity = 0.4f;
            //load the original file
            PdfDocument doc2 = new PdfDocument();
            doc2.LoadFromFile("Original.pdf");
            //Create the template from doc1
            PdfTemplate template = doc1.Pages[0].CreateTemplate();
            foreach (PdfPageBase page in doc2.Pages)
            {
                //set PDF overlay effect and set transparency mode
                page.Canvas.SetTransparency(0.1f, 0.1f, PdfBlendMode.Overlay);
                //draw template
                page.Canvas.DrawTemplate(template, PointF.Empty);
            }
            //Save pdf file.
            doc2.SaveToFile("result.pdf");

Sincerely,
Sara
E-iceblue support team
User avatar

Sara.Yang
 
Posts: 33
Joined: Wed May 06, 2020 1:05 am

Return to Spire.PDF