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.

Thu Feb 15, 2018 6:14 pm

Hi,

I am trying to replace an image in header of the PDF document but ReplaceImage function is not working.

Any help would be greatly appreciated.

rishabhjain86
 
Posts: 6
Joined: Thu Feb 15, 2018 3:52 pm

Fri Feb 16, 2018 2:06 am

Hello,

Thanks for your inquiry. Could you please share the document you were trying for our investigation? After then, we will provide you the solution accordingly.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Feb 16, 2018 3:24 pm

I have attached the document, I need to replace the logo (2nd page and thereafter) with different image.

rishabhjain86
 
Posts: 6
Joined: Thu Feb 15, 2018 3:52 pm

Mon Feb 19, 2018 3:19 am

Hello,

Thank you for providing further information.
The logo you mean is not image. In your pdf file, in fact there are no images.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Feb 26, 2018 8:36 pm

I have attached another document in which CSC logo is an image and replaceimage function is not working to replace this image.

Any help would be greatly appreciated.

rishabhjain86
 
Posts: 6
Joined: Thu Feb 15, 2018 3:52 pm

Tue Feb 27, 2018 3:00 am

Dear rishabhjain86,

Thanks for your file.
I have tested your document with the latest Spire.PDF Pack(Hot Fix) Version:4.2.8, I could replace the logo image successfully. Please try to use this version.
One thing which deserves our attention is that Spire replaces image by image index. I found the index of logo image on page 6 was 1, which is different from that of other pages. So please use following code to replace the logo image on all pages.
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(FilePath + "Logo Test.pdf");
            PdfImage image = PdfImage.FromFile(@"F:\image1.jpg");
            for (int i = 0; i < doc.Pages.Count; i++)
            {
                PdfPageBase page = doc.Pages[i];
                if (i != 5)
                {
                    page.ReplaceImage(0, image);
                }
                else
                    page.ReplaceImage(1, image);
            }
            doc.SaveToFile("12967.pdf");

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

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Feb 27, 2018 8:47 pm

Thanks for your reply.

Can you please let me know how can I find index of an image on a particular page? As you said, index of logo was different on page '6' so want to know how did you find it?

Also this version of Spire.PDF 4.2.8 creates a watermark "Evaluation Warning : The document was created with Spire.PDF for .NET." but it doesn't come when I use free version Spire.PDF 3.x.x, so how can I eliminate this message?

Thanks in advance!

rishabhjain86
 
Posts: 6
Joined: Thu Feb 15, 2018 3:52 pm

Wed Feb 28, 2018 3:19 am

Dear rishabhjain86,

Thanks for your inquiry.
As for the index of the image, it depends on the drawing order on the page. The logo image on the page 6 is the second image to be drawn, so the index is 1. I used the tool "PDFPatcher" to check the index of the image. You could check the information of the image on page 6 as below.
screenshot.jpg


As for the message, the version I mentioned is commercial version, so there will be that warning information without applying valid license. So sorry that we don't have the plan to update free version at present. But our sales team has sent you a 1-month free license of Spire.PDF to help removing the warning message, then you could have better evaluating on our product. Please refer to the following guidance on how to apply license.
https://www.e-iceblue.com/Tutorials/Lic ... ply_by_Key
Any question, please feel free to let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Mar 07, 2018 8:27 am

Dear rishabhjain86,

Greetings from E-iceblue.
How is your issue now ? Could you please give us some feedback at your convenience ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF