#1 2011-04-17 20:19:23

photofritz
Member
Registered: 2011-04-16
Posts: 14

Canvas pen width versus PDF pen width

I hope to explain myself, but when I set the pen width to one pixel and draw on the VCLCanvas of a TPdfDocumentGDI, the line width comes out relatively thick, and I can't set the line width any smaller than 1 as Canvas.Pen.Width is an integer. Setting to zero doesn't help.

I need to draw a tiny width line on paper. Is there a way to achieve this with VCLCanvas? I know it can be done with PDF.Canvas, but I would have to change alot of code for compatibility
Thanks
FRITZ

Offline

#2 2011-04-18 07:06:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Canvas pen width versus PDF pen width

You could increase the ScreenLogPixels value, so that it will increase the resolution of the VCLCanvas.
Default value is 72, but you could set it e.g. to 144.
The ScreenLogPixels must be set before the first use of VCLCanvas.

  lPdf := TPdfDocumentGDI.Create;
  try
    lPdf.ScreenLogPixels  := 144;
    lPdf.Info.Author        := 'Tester';
  (...)

In this case, a VCLCanvas.Pen.Width of 1 will be smaller when rendered on pdf content.

Offline

#3 2011-04-18 11:00:02

kalwados
Member
Registered: 2011-04-18
Posts: 15

Re: Canvas pen width versus PDF pen width

ab wrote:

You could increase the ScreenLogPixels value, so that it will increase the resolution of the VCLCanvas.
Default value is 72, but you could set it e.g. to 144.
The ScreenLogPixels must be set before the first use of VCLCanvas.
[...]
In this case, a VCLCanvas.Pen.Width of 1 will be smaller when rendered on pdf content.

I'm in the same situation to change the resolution, and I was very happy to read the "solution" here. Unfortunately "ScreenLogPixels" is a read only property (Version 1.12).

Please assist.
TIA

Offline

#4 2011-04-18 17:46:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Canvas pen width versus PDF pen width

ScreenLogPixels is read and write in version 1.13.

Version 1.13 is to be released in the next hours (or days).

Offline

#5 2011-06-15 16:49:02

Safetydan
Member
Registered: 2011-06-09
Posts: 4

Re: Canvas pen width versus PDF pen width

Did this solution work for you guys?

It didn't seem to for me.  I tried setting ScreenLogPixels to 960 as a test and the rectangle still came out as 2 pixels thick.  Setting ScreenLogPixels is working properly in terms of changing the resolution of the VCLCanvas, but does not seem to be changing the thickness of the lines as hoped.

Here is my rectangle draw code, FCanvas is set to the PDFDocumentGDI's VCLCanvas.  The value being passed in for aWeight is 0.  In the on-screen display of the canvas the lines are 1 pixel thick.

procedure drawbox(aWidth, aHeight: TInches; Color: TColor; PenStyle: TPenStyle; weight: integer);
var rect: TRect;
begin
    // set the pen for the boundary
    FCanvas.pen.Width := aWeight
    FCanvas.pen.style := aStyle;
    
    with FCanvas do begin
        rect.left := FPositionX;
        rect.Top := FPositionY;
        rect.Right := FPositionX + aWidth;
        rect.Bottom := rect.Top + aHeight + 1;

        brush.Style := bsClear;
        Rectangle( rect );
    end;
end;

Last edited by Safetydan (2011-06-15 16:50:33)

Offline

#6 2011-06-16 13:06:29

Safetydan
Member
Registered: 2011-06-09
Posts: 4

Re: Canvas pen width versus PDF pen width

Just and update.  Using a width of 1 instead of 0 solved my problem.

Offline

Board footer

Powered by FluxBB