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

FreeText Annotation Error in UWP

Hello
According to https://www.syncfusion.com/products/file-formats/pdf in "FEATURE MATRIX" in "Annotation Types" section it shows that "FreeText Annotation" are supported in UWP.

BUT

Below code gives me error : "Unable to cast object of type 'Syncfusion.Pdf.Interactive.PdfPopupAnnotation' to type 'Syncfusion.Pdf.Interactive.PdfLoadedAnnotation'."

                    Stream fileStream = randomAccessStream.AsStreamForRead();
                    byte[] buffer = new byte[fileStream.Length];
                    fileStream.Read(buffer, 0, buffer.Length);
                    PdfLoadedDocument ldoc = new PdfLoadedDocument(buffer);
                    //Creates a rectangle
                    System.Drawing.RectangleF rectangle = new System.Drawing.RectangleF(10, 40, 30, 30);
                    //Creates a new popup annotation.
                    PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(rectangle, "Test popup annotation");
                    popupAnnotation.Border.Width = 4;
                    popupAnnotation.Border.HorizontalRadius = 20;
                    popupAnnotation.Border.VerticalRadius = 30;
                    //Sets the pdf popup icon.
                    popupAnnotation.Icon = PdfPopupIcon.NewParagraph;
                    //Adds the annotation to loaded page
                    ldoc.Pages[0].Annotations.Add(popupAnnotation);
                    //Saves the document to disk.
                    await ldoc.Save();
                    pdfViewer.LoadDocument(ldoc);

I also tried below code.
 
            //Create a new rectangle
            System.Drawing.RectangleF textAnnotationBounds = new System.Drawing.RectangleF(10, 40, 100, 30);
            //Create a new line annotation.
            PdfFreeTextAnnotation textAnnotation = new PdfFreeTextAnnotation(textAnnotationBounds);
            //Set the text and font
            textAnnotation.MarkupText = "Text Annotation";
            textAnnotation.Font = new PdfStandardFont(PdfFontFamily.Courier, 10);
            //Set the line caption type.
            textAnnotation.AnnotationIntent = PdfAnnotationIntent.FreeTextCallout;
            //Add this annotation to a new page.
            ldoc.Pages[0].Annotations.Add(textAnnotation);
            await ldoc.Save();
                    pdfViewer.LoadDocument(ldoc);

Can you provide me UWP example which supports "FreeText Annotation" and all other Annotation.

Thanks in advance.


3 Replies

DH dhaval January 3, 2017 06:23 AM UTC

Sorry but i am not able to find any option to modify my thread.

I want to update title of thread.

"FreeText Annotation Error in UWP"

Thanks.


DH dhaval January 4, 2017 03:00 PM UTC

Update:

Be below code i am able to create Free Text Annotation :).
But SfPdfViewerControl is not able to show it :( .
When i save and export that PDF, Adob reader is able to show that Annotation!!.
I Have attached Output file.

            //Creates a rectangle
            PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new System.Drawing.RectangleF(40, 40, 100, 50));
            //Sets properties to the annotation
            freeText.MarkupText = "Free Text with Callouts";
            freeText.TextMarkupColor = new PdfColor(System.Drawing.Color.FromArgb(0, 0, 0, 0));
            freeText.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 7f);
            freeText.Color = new PdfColor(System.Drawing.Color.FromArgb(0, 0, 255, 0));
            freeText.BorderColor = new PdfColor(System.Drawing.Color.FromArgb(0, 255, 0, 0));
            freeText.Border = new PdfAnnotationBorder(1);
            freeText.Text = "Free Text";
            freeText.Opacity = 1;
            //Adds the annotation to page
            ldoc.Pages[0].Annotations.Add(freeText);
          
            MemoryStream memoryStream = new MemoryStream();

            //save the document into stream
            //await ldoc.Save();
            await ldoc.SaveAsync(memoryStream);

Attachment: output112_7bff943a.zip


SK Surya Kumar Syncfusion Team January 5, 2017 01:02 PM UTC

Hi Dhaval, 

Thank you for using Syncfusion products. 

At present, we do not have support for “FreeText annotation in PDF viewer”, so the free text annotations are not visible while displaying the documents using PDF viewer. After implementing this feature, we can view the free text annotation in PDF viewer. 
 
We will implement this feature in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity.   
 
At present PDF Viewer supports the below features, 

·       Ink annotation. 

·       Text markup annotation [Highlight, Underline and Strikeout]. 

·       Shape annotation [Line, Rectangle and Ellipse]. 

We have attached the video demo for using the annotations supported by SfPdfViewerControl and it will be downloaded from the below link,

Video link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/Video470738390
 

We have also attached a sample for the same and it will be downloaded from below link, 
Let us know if you need any further assistance regarding this. 

Regards, 

Surya Kumar 


To post a reply.
Loader.
Live Chat Icon For mobile
Up arrow icon