Search code examples
pdfclown

How to set no border when drawing background colored rectange?


Is there a way to set no border when drawing background-color filled rectangle? Or make border color match background-color filled rectange?

PrimitiveComposer primitiveComposer = new PrimitiveComposer(page);
{
    BlockComposer blockComposer = new BlockComposer(primitiveComposer);

    primitiveComposer.SetLineWidth(0.0f);
    primitiveComposer.SetFillColor(DeviceRGBColor.Get(System.Drawing.Color.DarkGray));
    primitiveComposer.DrawRectangle(new RectangleF(_boxMarginX, _boxMarginY, (page.Size.Width - (_boxMarginX * 2)), 205f), 0f);
    primitiveComposer.FillStroke();
}

Solution

  • You use

    primitiveComposer.FillStroke();
    

    which is the command to fill and stroke a path. As you don't want the borders, i.e. you don't want to stroke, use

    primitiveComposer.Fill();
    

    instead.

    By the way,

    primitiveComposer.SetLineWidth(0.0f);
    

    The PDF specification defines a line width of 0 to mean the smallest line the target device can render.