Free Support Forum - aspose.com

Is hover possible in PDF using Aspose.pdf/Aspose.words?

Hi,

I have requirement in which I need to convert HTML to PDF, Html has track change details like underline for insertion and strike for deletion, After pdf conversion when the user hover over any of the track changed text he should be able to view the username .

Is it possible to do if yes can you help me with the steps

Regards,

Divesh Salian

Hi Divesh,

Thanks for your interest in our products.

Aspose.Pdf for .NET supports the feature to convert HTML file to PDF format but I am afraid in order to render the formatting of text (underline and strike-through), the source HTML should have text formatted in Underline and Strike-through. Now concerning to you requirement "when the user hover over any of the track changed text he should be able to view the username" you may consider adding JavaScript to PDF file on specific location or in case you do not need to add JavaScript, you can add annotation with username information and viewer can click specific annotation and see the username. Please visit the following links for further information on


In case I have not properly understood your requirement or you have any further query, please feel free to contact.

Giving you a brief details....

We have document which has Track change details like User who enter new text, deleted text, changed the font.....

After we convert this document to PDF, We want to have something like when user moves the mouse over edited text/ deleted text he should be able to view the username/datetime in tool tip who has edited that.

We have all the details of user like deleted text,datetime etc

For better understanding here is a quick related example

http://examples.itextpdf.com/results/part2/chapter07/timetable_help.pdf

when I move the mouse over differnet QuestionMark image am able to view the differnet tooltip.

I want the same to happen but on text

If anything more needed let me know

Regards,

Divesh Salian

Hi Divesh,


Thanks for sharing the details.

I am pleased to share that your above stated requirement can be accomplished using TextAnnotation class of Aspose.Pdf for .NET. Please try using the following code snippet to add annotation to existing PDF document. For your reference, I have also attached the resultant PDF file which I have generated. Please take a look.

For further information, also please take a look over Add Annotation in an Existing PDF File

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/Sample.pdf");

//create annotation

TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));

textAnnotation.Title = "Sample Annotation Title";

textAnnotation.Subject = "Sample Subject";

textAnnotation.State = AnnotationState.Accepted;

textAnnotation.Contents = "Sample contents for the annotation";

textAnnotation.Open = false;

textAnnotation.Icon = TextIcon.Help;

Border border = new Border(textAnnotation);

border.Width = 5;

border.Dash = new Dash(1, 1);

textAnnotation.Border = border;

textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600);

//add annotation in the annotations collection of the page

pdfDocument.Pages[1].Annotations.Add(textAnnotation);

////save output file

pdfDocument.Save(“c:/pdftest/Annotation_output.pdf”);

Hi,

Thanks for the help....

Instead of having QuestionMark image can I do that on text... Say When user moves the pointer over that text he is able to view it.

EG....

http://examples.itextpdf.com/results/part2/chapter07/movie_posters_2.pdf

In this there are different image and on each image annotation is displayed.

same we need to achieve for text

If yes can you please share the code....

Regards,

Divesh Salian

Hi Divesh,


Thanks for sharing the details.

As per my understanding, you need to add annotation on top of some text but you do not want to display any icon i.e. question mark or something. Please share some details so I may update/provide details accordingly.

Hi Nayyer,

I don't want any icon... annotation should be displayed directly on text....

A same like MS WORD trackchange.....

Thanks & Regards,

Divesh Salian

Hi Divesh,


Thanks for sharing the details.

I am afraid currently Aspose.Pdf for .NET does not support the feature to add TextAnnotation without any Text Icon. However for the sake of implementation, I have logged this
requirement in our issue tracking system under New Features list as
PDFNEWNET-34751.
We will further investigate this requirement in details and will keep you
updated on the status of a correction.

We apologize for your inconvenience.

Hi Divesh,


Thanks for your patience.

We have further looked into the requirement of adding TextAnnotation without icon and I am afraid this feature cannot be implemented. Please note that TextAannotations can be represented with any of the following predefined icons: Comment, Key, Note, Help, NewParagraph, Paragraph, Insert (even-though additional names can be supported as well). These names can be seen in TextIcon enum. Adobe Specifications state that default value for text annotation is Note, which means that in spite of our wish, TextAnnotation will always be represented as icon. Please take a look over the following code snippet:

[C#]

Document pdfDocument = new Document(@“c:/pdftest/MinRow_34042_WithTable.pdf”);<o:p></o:p>

TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));

textAnnotation.Title = "Sample Annotation Title";

textAnnotation.Subject = "Sample Subject";

textAnnotation.State = AnnotationState.Accepted;

textAnnotation.Contents = "Sample contents for the annotation";

textAnnotation.Open = false;

Border border = new Border(textAnnotation);

border.Width = 5;

border.Dash = new Dash(1, 1);

textAnnotation.Border = border;

textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600); pdfDocument.Pages[1].Annotations.Add(textAnnotation);

pdfDocument.Save(@"c:/pdftest/BodyPDF (1)_Hello_output.pdf");


The output PDF Hello_output.pdf does not define icon for text annotation (try to find /Name entry)

<</Subj(Sample Subject)/State(Accepted)/Subtype/Text/F 4/P 16 0 R/BE<>/BS<>/T(Sample Annotation Title)/Open false/Rect[200 400 400 600]/Contents(Sample contents for the annotation)/Type/Annot>>

But Acrobat Reader shows text annotation using Note icon, i.e. which is the default value. We are sorry for this inconvenience.