#1 2011-06-12 14:16:18

Gemsys
Member
Registered: 2011-06-12
Posts: 6

Position of Objects on the canvas

Have been playing with

   pdfDoc.Canvas.DrawXObject(0, 0 ,   250 , 300, objectname);

which appears to place objects in the "natural" position rather than their standard Delphi/Windows position.  That is the code above would place the bottom left of the object at the ** bottom ** left corner, rather than placing the top left of the object at the top left corner of the canvas as with other Delphi items including for example:

   pdfDoc.VCLCanvas.TextOut( 0,0, 'The quick brown fox jumped over the lazey dog');

which places the top left of the text at the top left of the canvas.

In order to place the object at the top left corner use:

   pdfDoc.Canvas.DrawXObject(0, pdfpage.PageHeight - Objectheight  ,   250 , 300, objectname);

Last edited by Gemsys (2011-06-12 14:30:58)

Offline

#2 2011-06-12 15:44:19

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

Re: Position of Objects on the canvas

As stated by the documentation, the Canvas property is a PDF Canvas, whereas VCLCanvas property is a VCL Canvas.

The Canvas property uses the standard Adobe PDF coordinate space. The origin of this space is at the bottom left of the document. Distances are measured up and to the right in points. Points are a traditional measure for print work - there are 72 points in an inch. Since the PDF Canvas use double as coordinates, you have virtually an infinite DPI.

So you are correct: the PDF Canvas has not the same orientation as with the VCL/Windows way.
The bottom-up PDF coordinate space is different from the top-down coordinate system often used in Windows.
It means that everything is based around the bottom left of objects - not the top left.

Offline

#3 2011-06-15 06:06:37

Gemsys
Member
Registered: 2011-06-12
Posts: 6

Re: Position of Objects on the canvas

OK, my main problem is not knowing where the documentation is.  Could somebody give me a reference please.  At the moment I am simply working by using examples given in this forum!

Thanks in advance
Geoff

Offline

#4 2011-06-15 06:16:13

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

Re: Position of Objects on the canvas

There is no documentation dedicated to the SynPdf unit yet.

In fact, the SynPdf documentation is all the comments in the source code, which are retrieved and made as document in the corresponding part of our ORM framework documentation (SAD document).
See http://synopse.info/forum/viewtopic.php?id=55

The Canvas and VCLCanvas comments in the code (in the interface part of the unit) should be detailed enough as reference.
For samples, you've got those in the forum.

IMHO the main gate to SynPdf is to use a TMetaFileCanvas and render it into a pdf.
So you'll use regular TCanvas methods to make the drawing (following the official documentation from the VCL), then you render it into a pdf file via the TPdfCanvas.RenderMetaFile method.
You could use also VCLCanvas if you don't have a TMetaFile content at hand (it will use in fact an hidden TMetaFile and expose its canvas).

But to use directly the Canvas property is not so easy: in this case, you'll have to read the official pdf reference document from Adobe, and check all the available TPdfCanvas methods comment.
You should know what you are doing.
But the resulting pdf won't be "better" than via a TMetaFile, IMHO.

Offline

Board footer

Powered by FluxBB