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 Apr 28, 2022 7:24 pm

I am evaluating Spire.PDF for use in our company. One requirement is that we can set images and text in source PDF template files that will be merged into one result file. This is dynamic based on the data. Currently we look up where the image should go based on the field name. That returns a PdfTextBoxFieldWidget. When I try to set the image on it, it throws a NullReferenceException. I don't see anything as being null. What am I doing wrong?

Code: Select all
        [TestMethod]
        public void TestSpirePdf()
        {
            var document = new Spire.Pdf.PdfDocument(PdfBuilderTests.TemplatePath);
            var formWidget = document.Form as PdfFormWidget;

            SetImageField(formWidget, "image_context", PdfBuilderTests.ImagePath);

            document.SaveToFile(PdfBuilderTests.OutputPath);
        }

        public void SetImageField(PdfFormWidget formWidget, string fieldName, string imageFileName)
        {
            var formFields = GetFieldsByName<PdfButtonWidgetFieldWidget>(formWidget, fieldName);
            var image = PdfImage.FromFile(imageFileName);

            foreach (var pdfButtonWidgetFieldWidget in formFields)
            {
                pdfButtonWidgetFieldWidget.SetButtonImage(image); //THIS IS WHERE THE EXCEPTION IS THROWN
            }
        }

bryanvagis
 
Posts: 4
Joined: Thu Apr 28, 2022 7:03 pm

Fri Apr 29, 2022 5:54 am

Hi,

Thank you for your inquiry.
I did an initial test using the latest version(Spire.PDF Pack(Hot Fix) Version:8.4.15), but didn't reproduce your problem. I suggest you give the latest one a try. If the problem still exists, please provide the following information for further investigation. You can attach your file here or send it to us via email (support@e-iceblue.com). Thanks in advance.
1) Your PDF test documents and images
2) Test environment, such as Win10, 64bit
3) Application type, such as Console App, .NET Framework 4.8

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Fri Apr 29, 2022 4:57 pm

Thanks for the response. I just sent an email containing a zip folder with the test files in it.

bryanvagis
 
Posts: 4
Joined: Thu Apr 28, 2022 7:03 pm

Mon May 02, 2022 2:36 am

Hi Bryan,

Thanks for your sharing.

I have reproduced the error using your PDF file and logged it in our bug tracking system with the ticket SPIREPDF-5165. If there is any progress or update, I will notify you in time. Sorry for the inconvenience caused.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon May 02, 2022 11:57 am

Thank you for following up on this. I look forward to seeing an update that fixes the issue.

bryanvagis
 
Posts: 4
Joined: Thu Apr 28, 2022 7:03 pm

Wed Jun 08, 2022 9:47 am

Hi Bryan,

Thanks for your patience!

Glad to inform you that we just released Spire.Pdf Pack(Hot Fix) Version:8.6.1 which fixes your issue SPIREPDF-5165.

Please download the fix version from the following links to test.
Website link:
https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link:
https://www.nuget.org/packages/Spire.PDF/8.6.1
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Jul 21, 2022 3:14 am

Hi,

Greetings from E-iceblue!
Have you tried the hotfix? Could you please give us some feedback at your convenience?

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Mon Aug 01, 2022 12:38 pm

Thank you for this fix! It does appear to work as expected now.

bryanvagis
 
Posts: 4
Joined: Thu Apr 28, 2022 7:03 pm

Tue Aug 02, 2022 2:14 am

Hi,

If you need assistance in the future, please don't hesitate to contact us.
Wish you all the best :D

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.PDF