TAdvPDFLib printing

My current solution is to output a Pdf print using the canvas.

I have to do several calculations to ensure the output looks the same, depending of the resolution.
"pixininchx:=getdevicecaps(myPDFprinter.canvas.handle,LOGPIXELSX);"

Using the AdvPDFLib, are the different resolutions handled automatically, setting the page size to A4, or do I still have to do calulations to place the columns correctly in my reports?

Regards,
Ole

The default DPI is 72, there are no automatic scaling calculations included, so all calculations have to be done manually.

Could you point me in the right direction how to calculate positions using the TAdvPDFLib. Is there a sample demo?

I want to print (make a PDF) in columns starting at a specific point, measured i centimeters.

"StartX1" at 2cm from the left edge, "StartX2" at 5cm and so on.

There is no Handle in TAdvPDFLib.Graphics?

Here is my current code for output to a printer:
pixincmx:=0;
pixincmy:=0;
pixininchx:=0;
pixininchy:=0;
strheight:=0;
pixininchx:=getdevicecaps(printer.canvas.handle,LOGPIXELSX);
pixininchy:=getdevicecaps(printer.canvas.handle,LOGPIXELSY);
pixincmx:=pixininchx/2.55;
pixincmy:=pixininchy/2.55;
printer.canvas.font.name:='Arial';
printer.canvas.font.size:=10;
printer.canvas.font.style:=[];
strheight:=printer.canvas.textheight('X');
// Heading
pos1x:=round(pixincmx*3.00);

Regards,
Ole

Hi,

You have the PixelsToMillimeters & MillimetersToPixels functions available to draw inside TAdvPDFLib. It does not have a handle, because the graphics are actually custom drawn graphics.

Hi

Thanks, but in which Unit are these functions declared?

I have: AdvPDFLib, Types, AdvGraphicsTypes, AdvPDFCoreLibBase.

It's not: AdvPdfLib.Graphics.PixelsToMillimeter?

Could you provide a small example, please :smiley:

Regards,
Ole

It is a global function available in AdvPDFLib unit.

uses
  AdvPDFLib, Types;

procedure TForm23.Button1Click(Sender: TObject);
var
  p: TAdvPDFLib;
  x1, x2, y1, y2: Single;
begin
  p := TAdvPDFLib.Create;
  try
    p.BeginDocument('test.pdf');
    p.NewPage;
    x1 := MillimeterToPixel(20); //2 cm from the left
    x2 := MillimeterToPixel(100); //10 cm from the left
    y1 := MillimeterToPixel(50); // 5 cm from the top
    y2 := MillimeterToPixel(120); // 12 cm from the top
    p.Graphics.DrawRectangle(RectF(x1, x2, y1, y2));
    p.EndDocument(True);
  finally
    p.Free;
  end;
end;