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 17, 2019 11:59 pm

Hello,

I am trying to set the icon for the push button but the image is never rendered. I tried to follow the same process described on https://www.e-iceblue.com/Tutorials/Spi ... -in-C.html but no luck till now. Below is my code.

Code: Select all
PdfFont fontpdf = new PdfFont(PdfFontFamily.TimesRoman, 15f, PdfFontStyle.Bold);
            PdfBrush brushpdf = PdfBrushes.Black;

            PdfButtonField pushButton = new PdfButtonField(page0, "PushButton")
            {
                ToolTip = "Testing of Push button",
                Bounds = new RectangleF(0, 0, 100, 100),
                BorderColor = Color.Aqua,
                BorderStyle = PdfBorderStyle.Underline,
                BorderWidth = 0.5f,
                ReadOnly = false,
                BackColor = Color.Beige,
                Export = true,
                Flatten = false,
                Font = fontpdf,
                ForeColor = Color.Red,
                HighlightMode = PdfHighlightMode.Push,
                //IconLayout = pushButtonIconLayout.Spaces
                //Location = new PointF(50,50),
                LayoutMode = PdfButtonLayoutMode.IconOnly,
                MappingName = "Push Button",
                Required = true,
                //RolloverIcon
                //RolloverText
                //Size = new SizeF(10,10),
                Text = "Chintal",
                TextAlignment = PdfTextAlignment.Center,
                Visible = true
            };

            pushButton.IconLayout.Spaces = new float[] { 25f, 10f };
            pushButton.IconLayout.ScaleMode = PdfButtonIconScaleMode.Proportional;
            pushButton.IconLayout.ScaleReason = PdfButtonIconScaleReason.IconIsBigger;
            pushButton.IconLayout.IsFitBounds = false;
            pushButton.Icon = PdfImage.FromFile(@"C:\PDF\_1.png");

            doc.Form.Fields.Add(pushButton);

            //save the file
            doc.SaveToFile(@"C:\PDF\Testing.pdf");

chintalpatel89
 
Posts: 16
Joined: Sun Dec 25, 2016 9:54 am

Mon May 20, 2019 6:53 am

Hello,

Thanks for your inquiry.
I did a test with our latest Spire.PDF Pack(Hot Fix) Version:5.5.1 and found the image could be rendered correctly. Please refer to my generated PDF file from the reply of another post. I suggest you try again with the latest version. If your issue still occurs after trying, please share us with the following more information to help further look into it. You could send them to us via email ([email protected]).
1. Your generated PDF.
2. What is the PDF reader you used? If you open the files in Adobe Acrobat, will the issue still happen?
3. Your system configuration (E.g. Win 7, 64 bit).
4. Your region setting (E.g. China, Chinese).

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Mon May 20, 2019 2:03 pm

I tried opening the same file which you had attached in foxit reader and it doesnt work properly while it does work with adobe reader. Below are details and screenshot attached.

1. Your generated PDF. --> attached screenshot
2. What is the PDF reader you used? If you open the files in Adobe Acrobat, will the issue still happen? --> foxit reader(Version: 9.5.0.20723). Yes, it does work with adobe reader. And even I can see images from my file when I open the same in adobe but not with foxit reader.
3. Your system configuration (E.g. Win 7, 64 bit). --> win 10 64-bit
4. Your region setting (E.g. China, Chinese). --> English Canada

chintalpatel89
 
Posts: 16
Joined: Sun Dec 25, 2016 9:54 am

Tue May 21, 2019 2:49 am

Hello,

Thanks for your more information.
I did notice that the push button image didn't render out when opening the generated PDF with Foxit reader. This issue has been logged into our bug tracking system for further investigating and fixing. Sorry for the inconvenience caused. We will keep you informed if there is any progress.

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Tue May 21, 2019 10:47 pm

Thank you very much. will be waiting for an update.

chintalpatel89
 
Posts: 16
Joined: Sun Dec 25, 2016 9:54 am

Wed May 22, 2019 1:23 am

Hello,

Thanks for your feedback.
Our Dev team is working on this issue now, once it is fixed, we will prepare a Hotfix version for you asap.

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Wed Mar 23, 2022 9:24 am

Hello,

Sorry for the long silence.
Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:8.3.9 which fixed the reported issue by using the below sample code, welcome to test it.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget: https://www.nuget.org/packages/Spire.PDF/8.3.9
Code: Select all
 //Create a PDF document
 PdfDocument doc = new PdfDocument();
 PdfPageBase page = doc.Pages.Add();
 PdfFont fontpdf = new PdfFont(PdfFontFamily.TimesRoman, 15f, PdfFontStyle.Bold);
 PdfBrush brushpdf = PdfBrushes.Black;
 PdfButtonField pushButton = new PdfButtonField(page, "PushButton")
 {
     ToolTip = "Testing of Push button",
     Bounds = new RectangleF(0, 0, 50, 50),
     BorderColor = Color.Aqua,
     BorderStyle = PdfBorderStyle.Underline,
     BorderWidth = 100f,
     ReadOnly = false, BackColor = Color.Beige, Export = true, Flatten = false, Font = fontpdf, ForeColor = Color.Red, HighlightMode = PdfHighlightMode.Push,
     LayoutMode = PdfButtonLayoutMode.IconOnly, MappingName = "Push Button", Text = "Chintal", TextAlignment = PdfTextAlignment.Center, Visible = true
 };
 pushButton.IconLayout.Spaces = new float[] { 25f, 10f };
 pushButton.IconLayout.ScaleMode = PdfButtonIconScaleMode.Proportional;
 pushButton.IconLayout.ScaleReason = PdfButtonIconScaleReason.IconIsBigger;
 pushButton.IconLayout.IsFitBounds = false;
 pushButton.Icon = PdfImage.FromFile(@"logo.png");
 doc.Form.NeedAppearances = false;// add code
 doc.Form.Fields.Add(pushButton);
 //save the file
 doc.SaveToFile(@"output.pdf");

Sincerely,
Lisa
E-iceblue support team
User avatar

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

Return to Spire.PDF