Non-Transparent Rectangle

  • When drawing a Rectangle from the demo, the default behavior is transparent. The Circle is NOT transparent.

    I'm looking for creating a non-transparent rectangle to redact large areas of text or images.

    I tried the sample code (from help):

    var

    t: TPDFDrawObjectRec;

    begin

    FillChar(t, SizeOf(t), 0);

    t.ColorBrush := clRed;

    t.Alpha := 100; // transparent

    t.grtyp := 1; // Rectangle

    WPViewPDF1.CommandStrEx(COMPDF_MouseAddOneDrawObject,

    'REDRECT', Cardinal(@t));


    and was able to put the mouse once into a drawing mode as a square with an arrow and a +, but no rectangle was drawn on the PDF. As soon as I began the drag with the mouse, the cursor changes to a multi-page glyph.

    After that initial draw attempt, this function failed to put the mouse into a drawing mode.

    I also tried multiple values for t.Alpha := XXX

    So, how can I turn off the transparency for the demo rectangle? If not possible, why does the above code fail?

    Thanks.

    • Offizieller Beitrag

    Alpha is defined like this:

    Alpha : Integer; // 0 or Alpha in range 1..255.

    So to make it opaque please either use the value 0 or 255. It is not a percentage values.

    COMPDF_MouseAddOneDrawObject purpose is to create a rectangle with the mouse. If you need to create it without user input you need

    You will not be able to select the object with the mouse since this command does not switch the mouse mode.

  • Thank you for that sample code, but it does not solve what I'm trying to do.

    I want to "Draw" a rectangle, and on completion of the draw, the rectangle appears.

    The Demo draws a rectangle, but the result is transparent.

    How do I turn off the default transparency, or draw a rectangle similar to how the demo draws?

    My attempts using COMPDF_MouseAddOneDrawObject failed as described earlier.

    You mentioned "...does not switch the mouse mode", is that what I'm missing?

    Please give sample to draw the rectangle similar to the demo, but no transparency, or show how to turn off transparency as the default.

    Thanks.