Annotation Edit Mode

  • I want to be able to turn on and off Annotation editing.
    I can turn it on with this:
    pdfViewer1.Command(commands.COMPDF_ACRO_MAKEDRAWOBJ, "", 8192);

    But I can't seem to figure out how to turn it off.

    • Offizieller Beitrag

    Hello,

    I recommend to use the new action mode as described in the manual -
    "Create a PDF Editor"

    or
    You can implement actions which change the ActionMode - COMPDF_SetActionMode

    The "ActionMode" controls how the user can interact with the editor.

    The ActionMode can be controlled by the actions as described with the sample application or it can be changed with this command: COMPDF_SetActionMode = 557
    This replaces the old command "SelectMode"

    COMPDF_SetActionMode expects and optional string parameter and an integer parameter which selects the mode:

    0 wpacUndefined, // ActionMode was not used yet
    1 wpacClickAndPan, // Standard Mode
    2 wpacSelectPage, // Select page by click
    3 wpacSelectObjects, // Select objects
    4 wpacSelectObjectsLocked, // Select objects, does not move them
    5 wpacFillForms, // Like wpacClickAndPan and allow widgets to be changed
    6 wpacDrawFrameAndZoom, // Zoom to rectangle, Copy rectangle, reset to wpacClickAndPan
    7 wpacDrawFrameAndCopyBitmap, // Copy rectangle, reset to wpacClickAndPan
    8 wpacSelectText, // Select text and invert visual
    8 wpacDrawFrameAndCopyText, // Draw a frame and copy the text within
    10 wpacSelectTextAndColor, // Select text and highlight.
    11 wpacSelectTextAndBlack, // Select text and black it out
    12 wpacSelectTextAndDelete, // Select text and delete (reserved)
    13 wpacDrawObject, // Draw a frame, create an object. Uses 2nd parameter
    14 wpacDrawObjectContinue, // Draw a frame, create an object.
    // Uses 2nd string parameter. Continue drawing
    15 wpacDrawAnnot, // Draw a frame, create an Annotation. Uses 2nd parameter
    16 wpacDrawAnnotContinue, // Draw a frame, create and the next ...
    17 wpacDrawField, // Draw a frame, create an Annotation. Uses 2nd parameter
    18 wpacDrawFieldContinue, // Draw a field, create, and the next
    19 wpacDrawFrameAndEvent, // Draw Frame and trigger the event

    The string parameter is used when creating objects, it can contains information such as the color or the text.

  • I don't seem to be able to find documentation to explain what all the options are for the 'param' parameter for a line line this:
    Param := Format('"Color=%s","Alpha=325"', [ColorStr]);
    wpViewPDF1.Command(COMPDF_SetActionMode, Param ,15);

    The above line of code draws a box that is filled with white and the border is the color selected.
    What I want is to draw a highlight box filled with ColorStr color.
    It seems that I need to add another parameter but I can find a reference to the parameter that would let me describe the box fill color.

    This line of code does what I want but is in the old format:
    vals[0] := 'DrawAnnotHighlight';
    ColorStr := ColorToString(cbHighlightColor.SelectedColor);
    vals[1] := Format('"Color=%s","Alpha=325"', [ColorStr]);
    if wpViewPDF1.CommandStr(COMPDF_ACTION, vals[0] + '=' + vals[1] )=-2 then

    Thanks

    • Offizieller Beitrag

    Hi,

    The PDFEdit.EXE has in the last menu Info the item "Annotation property Peek" - it will display a window with the XML code for the annotation under the mouse cursor. This makes it possible to quickly check the properties of each annotation.

    The parameter names can also be used with COMPDF_SetActionMode, i.e. "Color=red"

    The following parameter names are inbuilt
    Color (used by annotations)
    Brush-Color (used by draw objects)
    Line-Color (only draw objects)
    Alpha
    Font
    Font-Size
    Font-Color
    Values (for combo box)

    Options which should be written to PDF can also be provided using the "prp." syntax. It is possible to create names, string, even nested objects.

    With prp.s.XX a PDF string is created with the name XX.

    Instead of s this characters are possible
    n - created pdf name
    v - create a value, usually a number
    a - an array, place it in brackets
    d - a dictionary which can be nested will be created

    prp.d.AA.s.JS=SomeCode will create a string JS "SomeCode" inside the dictionary AA

  • You provided me previously with the list for COMPDF_SetActionMode:

    0 wpacUndefined, // ActionMode was not used yet
    1 wpacClickAndPan, // Standard Mode
    2 wpacSelectPage, // Select page by click
    3 wpacSelectObjects, // Select objects
    4 wpacSelectObjectsLocked, // Select objects, does not move them
    5 wpacFillForms, // Like wpacClickAndPan and allow widgets to be changed
    6 wpacDrawFrameAndZoom, // Zoom to rectangle, Copy rectangle, reset to wpacClickAndPan
    7 wpacDrawFrameAndCopyBitmap, // Copy rectangle, reset to wpacClickAndPan
    8 wpacSelectText, // Select text and invert visual
    8 wpacDrawFrameAndCopyText, // Draw a frame and copy the text within
    10 wpacSelectTextAndColor, // Select text and highlight.
    11 wpacSelectTextAndBlack, // Select text and black it out
    12 wpacSelectTextAndDelete, // Select text and delete (reserved)
    13 wpacDrawObject, // Draw a frame, create an object. Uses 2nd parameter
    14 wpacDrawObjectContinue, // Draw a frame, create an object.
    // Uses 2nd string parameter. Continue drawing
    15 wpacDrawAnnot, // Draw a frame, create an Annotation. Uses 2nd parameter
    16 wpacDrawAnnotContinue, // Draw a frame, create and the next ...
    17 wpacDrawField, // Draw a frame, create an Annotation. Uses 2nd parameter
    18 wpacDrawFieldContinue, // Draw a field, create, and the next
    19 wpacDrawFrameAndEvent, // Draw Frame and trigger the event

    Then you referred me to the PDFEdit demo.
    However that demo, to me, is fairly cryptic since when I search for SetActionMode there only two references.

    So, I am still looking for documentation that more clearly explains the usage or a demo that actually contains code to show how to manually implement these actions. There is a lot going on in the PDFEdit demo but it is hard to determine what is going on since most of the actions seem to be loaded at runtime and so can't be accessed directly as a tutorial.

    Your help is appreciated.

    • Offizieller Beitrag

    Hi,

    I think I sent you a mail already, but in case anybody else has this question:

    How the PDFEdit demo is built described in the PDF manual. It uses the new inbuilt "actions" - that are named commands. The name of the commands should be self explanatory.

    Using the PDFEdit demo in menu "Demo" it is possible to extract the "Action XML script". That is XML data which containes the name, the caption and the hint for each action. That XML can be also used to translate the internal actions.

    The PDF edit simply calls the action methods in a loop to build the toolbar and the menu. To do so each available action name (or id) is retrieved and stored. When the menu or toolbar is clicked the name or id is used to execute a function in the DLL.

    The COMPDF_SetActionModeworks differently. It simply changes the current mouse mode. It is internally used by the actions mentioned above.

    I recommend to use the action names using this commands, most important COMPDF_ACTION which simply gets the name of the action


    // ------------ GUI Interface - Actions
    COMPDF_ACTION = 580; // Execute Action. StrParam : ActionName=ActionStrParam, IntParam as required
    COMPDF_ACTIONNR = 581; // HighWord=Kind, LowWord = Operation, StrParam is passed
    COMPDF_ACTIONEX=582; // Extended Action - with param as record (RESERVED)
    COMPDF_ACTION_READ = 583; // Read Action Properties

    // strparam="?actionname" returns the command id (HighWord=Kind, LowWord=Operation)
    // for the action with the name actionname. Returns 0 if not found.
    // strparam="xml" - read all strings and commands as XML list!
    // Yoi can localize the strings and use COMPDF_ACTION_WRITE to write the string back.
    // strparam="actionnames" - read all action names with their description in the format name=caption. If bit 1 is set in intpar
    // ;hint will be written, if bit 2 is set, ***Action kind captions will be written

    // strparam="caption", IntParam = HighWord=Kind, LowWord=Operation. Result can be ''
    // strparam="hint", IntParam = HighWord=Kind, LowWord=Operation. Result can be ''
    // strparam="command", IntParam = HighWord=Kind, LowWord=Operation. Result can be ''

    // The following will return integer values!

    // strparam="kinds" - read count of kinds
    // strparam="kindX" - read count of opertions in kind X
    // strparam="flags", IntParam = HighWord=Kind, LowWord=Operation. Read action flags for this action
    // strparam="param", IntParam = HighWord=Kind, LowWord=Operation. Read the param bitfield as Integer (not string)
    // strparam="paramkind", IntParam = HighWord=Kind, LowWord=Operation. Read the parameter kind as Integer (not string)

    COMPDF_ACTION_WRITE = 584; // Write <?xml, caption=, hint=, command=.., option=.. to modify the action. IntParam as above (except xml)
    COMPDF_ACTION_READFLAGS = 585; // Read Action flags, optimzed COMPDF_ACTION_READ "flags"
    COMPDF_ACTION_READSTATE = 586; // Read Action state, 1=checked, 2=disabled