Welcome to the WPF feedback portal. We’re happy you’re here! If you have feedback on how to improve the WPF, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

2
Votes

Dear, 


I need to modify all internal hyperlinks zoom setting, to inherit zoom. 


I use below code to generate a sample PDF, and try to modify the Destination.Zoom property, but not working.  


private void button_Click(object sender, RoutedEventArgs e)

        {

            //Create a new PDF document.

            PdfDocument document = new PdfDocument();

            //Create a new page.

            PdfPage page = document.Pages.Add();

            //Create a new rectangle.

            RectangleF docLinkAnnotationBounds = new RectangleF(10, 40, 30, 30);


            //Create a new document link annotation.

            PdfDocumentLinkAnnotation documentLinkAnnotation = new PdfDocumentLinkAnnotation(docLinkAnnotationBounds);

            //Set the annotation flags.

            documentLinkAnnotation.AnnotationFlags = PdfAnnotationFlags.NoRotate;

            //Set the annotation text.

            documentLinkAnnotation.Text = "Document link annotation";

            //Set the annotation's color.

            documentLinkAnnotation.Color = new PdfColor(System.Drawing.Color.Navy);

            //Creates another page.

            PdfPage navigationPage = document.Pages.Add();

            //Set the destination.

            documentLinkAnnotation.Destination = new PdfDestination(navigationPage);

            //Set the document link annotation location.

            documentLinkAnnotation.Destination.Location = new System.Drawing.Point(10, 0);

            //Set the document annotation zoom level.

            documentLinkAnnotation.Destination.Zoom = 2f; //<<<<========================== 200% zoom

            //Add this annotation to a new page.

            page.Annotations.Add(documentLinkAnnotation);


            //Save the document to disk.

            document.Save("DocumentLinkAnnotation.pdf");

            //Close the document.

            document.Close();

        }


        private void button1_Click(object sender, RoutedEventArgs e)

        {

            //Load the existing PDF document.

            PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"DocumentLinkAnnotation.pdf");

            //Load the page.

            PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;

            //Create a new rectangle.

            RectangleF docLinkAnnotationBounds = new RectangleF(10, 40, 30, 30);


            //Create a new document link annotation.

            PdfDocumentLinkAnnotation documentLinkAnnotation = new PdfDocumentLinkAnnotation(docLinkAnnotationBounds);

            //Set the annotation text.

            documentLinkAnnotation.Text = "Document link annotation new";

            //Set the existing page for navigation.

            PdfLoadedPage navigationPage = loadedDocument.Pages[1] as PdfLoadedPage;

            //Set the pdf destination.

            documentLinkAnnotation.Destination = new PdfDestination(navigationPage);

            //Set the document link annotation location.

            documentLinkAnnotation.Destination.Location = new System.Drawing.Point(20, 20);

            documentLinkAnnotation.Destination.Zoom = 0f;

            //Add this annotation to respective page.

            loadedPage.Annotations.Add(documentLinkAnnotation);



            //Get all the pages.

            foreach (PdfLoadedPage myloadedPage in loadedDocument.Pages)

            {



                //reset all the annotations inherit zoom in the page

                foreach (var annotation in myloadedPage.Annotations)

                {

                    //Check for the circle annotation

                    if (annotation is PdfLoadedDocumentLinkAnnotation)

                    {

                        //inherit zoom

                        PdfLoadedDocumentLinkAnnotation myanno = (PdfLoadedDocumentLinkAnnotation)annotation;

                        myanno.Destination.Zoom = 0f; //<<<<========================== iherit zoom

                    }

                }

            }


            //Save the document to disk.

            loadedDocument.Save("DocumentLinkAnnotation_new.pdf");

            //Close the document.

            loadedDocument.Close();

        }