Is it possible to markup (i.e. highlight or underline) text in a deployed cdf file and then save it? I think I know the answer (no), but since it seems a basic necessity for a document format that aspires to be used for textbooks, I thought I would ask if anybody had succeeded in such a task. Other similar tasks might include margin notes.

I have tried a little out myself and failed with the following code:

    highlight :=  
      SetOptions[NotebookSelection[EvaluationNotebook[]], Background -> Yellow];
    highlightButton := Button["Highlight", highlight];
     DockedCells -> Cell[BoxData[ToBoxes[highlightButton]], "DockedCell"]]

When this is executed in Mathematica, I get a nice Button in my DockedCell that allows me to highlight text, by first selecting the text and then hitting the button. However, this functionality disappears when I try to deploy as a CDF.

Am I right that this is impossible? I am pretty sure that even if I managed to get the text highlighted, from CDF Player, there won't be any saving anyway, but at least it could be printed (perhaps to a pdf).


1 Answer 1


Yes and no: Any alteration of the notebook by SetOptions seems to be inhibited (and that is probably fine). However, if you use Dynamic in advance for highlighting say a Text cell, then it works, even printing the highlighted cell to PDF. Try this:

highlightButton := Button["Highlight", color = RGBColor[1, 1, 0]];
unhighlightButton := Button["UnHighlight", color = RGBColor[1, 1, 1]];
  DockedCells -> 
     RowBox[{ToBoxes[highlightButton], ToBoxes[unhighlightButton]}]], 
CellPrint@Cell["CDF is really easy!", "Text",
   Background -> Dynamic[color]]
  • $\begingroup$ That certainly makes it possible for the user to switch back and forth, but it is not exactly what I am after. I would like to have the end-user have the ability to mark up sections that are of interest to him/her as they would be able to a printed book. My end use is a small textbook that I am in the throes of writing, and since it relies on extensive Dynamic interactivity, the printed version will lack substantially. What I would like to be able to do is have users be able to mark it up like they would the printed version. $\endgroup$ Mar 9, 2014 at 8:44
  • $\begingroup$ Call Wolfram Research and ask them to add this to the next version of CDF. $\endgroup$ Mar 9, 2014 at 8:57
  • $\begingroup$ That is a good idea. Maybe others would have some ideas of similar types of behavior that would be good to ask for. $\endgroup$ Mar 9, 2014 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.