We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Why does the last link just opens the file location of the pdf ?

My code

   document.PageSettings.Orientation = PdfPageOrientation.Landscape;
                        PdfPage page = document.Pages.Add();

                        PdfGraphics graphics = page.Graphics;
                        PdfBitmap image = new PdfBitmap(ImageFilenames[i]);


                        float ftImageWidth;
                        float ftImageHeight;
                        float ftPageWidth;
                        float ftPageHeight;

                        float.TryParse(image.Width.ToString(), out ftImageWidth);
                        float.TryParse(image.Height.ToString(), out ftImageHeight);
                        ftPageWidth = page.Graphics.ClientSize.Width;
                        ftPageHeight = page.Graphics.ClientSize.Height;


                        float myWidth = image.Width;
                        float myHeight = image.Height;
                        float shrinkFactor=1.3f;
 
                        if (myWidth > ftPageWidth)
                        {

                            shrinkFactor = myWidth / ftPageWidth;
                            myWidth = ftPageWidth;
                            myHeight = myHeight / shrinkFactor;
                        }

                        if (myHeight > ftPageHeight)
                        {
                            shrinkFactor = myHeight / ftPageHeight;
                            myHeight = ftPageHeight;
                            myWidth = myWidth / shrinkFactor;
                        }

                        graphics.DrawImage(image, (ftPageWidth - myWidth) / 2, (ftPageHeight - myHeight) / 2, myWidth, myHeight);

                        //graphics. = image.Width * 0.3f;
                        //float height = image.Height * 0.3f;

                        PdfTextWebLink textLink = new PdfTextWebLink();

                        string[] nameGesplittet = Path.GetFileNameWithoutExtension(ImageFilenames[i]).Split('#');

                        if (nameGesplittet.Length > 1)
                        {
                            graphics.DrawString(Path.GetFileNameWithoutExtension(ImageFilenames[i]), font, PdfBrushes.Red, new PointF(0, 35));

                            textLink.Url = "https://www.google.cz/search?hl=en&site=imghp&tbm=isch&source=hp&q=" + nameGesplittet[1].Trim();
                            textLink.Text = "Google Suche(cz)";
                            textLink.Font = font;
                            textLink.DrawTextWebLink(page, new PointF(0, 65));


                            textLink.Url = "https://translate.google.com/#de/cs/" + nameGesplittet[0].Trim();
                            textLink.Text = "Google translate(deutsch)";
                            textLink.Font = font;
                            textLink.DrawTextWebLink(page, new PointF(0, 95));

                            textLink.Url = "https://translate.google.com/#cs/de/" + nameGesplittet[1].Trim();
                            textLink.Text = "Google translate(tschechisch)";
                            textLink.Font = font;
                            textLink.DrawTextWebLink(page, new PointF(0, 125));
                        }



                        #endregion


                        Console.WriteLine((i + 1) + ": " + Path.GetFileName(ImageFilenames[i]));
                        GC.Collect();



Attachment: links_d936d861.7z

1 Reply

CM Chinnu Muniyappan Syncfusion Team September 19, 2016 10:46 AM UTC

Hi Mvxyc, 
 
Thank you for contacting Syncfusion support. 

We are not able to reproduce the issue, we have created a sample which we tried to reproduce the issue. Could you please modify the sample to reproduce the issue, it would more helpful for us to investigate further on this. 

Sample link: 
 
Regards, 
Chinnu 


Loader.
Up arrow icon