Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed May 23, 2018 2:17 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [DynaPDF] Working with centimeters and inches
PostPosted: Sun Jan 18, 2009 5:37 am 
Offline

Joined: Fri Mar 09, 2007 2:04 am
Posts: 92
Location: Venice, Italy
I'm trying to create a PDF document using the DynaPDF library. Since I want to create an A4 document and put the text inside the document with some margins, I'm trying to work with the metric standard. So I wrote:

Dim PDF As New DynapdfMBS
Dim oPDFFile As New FolderItem

oPDFFile = GetFolderItem("test.pdf")
Call PDF.CreateNewPDF(oPDFFile)
Call PDF.SetPageFormat(PDF.kpfDIN_A4) ' Set the page format to "A4" (21cm x 29.7cm)
Call PDF.SetResolution(150) ' Set the resolution to 150 DPI (Dot per Inch)

Call PDF.Append()
Call PDF.SetFont("Times", PDF.kfsNone, 16, True, PDF.kcp1252)
Call PDF.SetPageCoords(PDF.kpcTopDown)

' -=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-

' And now some values

Dim nOriginalWidth As Double = PDF.GetPageWidth() ' Returns: 595
Dim nWidthInInches As Double = nOriginalWidth / PDF.GetResolution() ' Returns: 595 / 150 = 3.9666667 Inches
Dim nWidthInCentimeters As Double = nWidthInInches * 2.54 ' Returns: 10.05733 Centimeters

' -=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-= -=-


PDF.EndPage
PDF.CloseFile

Quit


If I understood correctly, methods GetPageWidth and GetPageHeight returns a value expressed in points, so I though I had to divide that number by the resolution. In this case 595 / 150 DPI = 3.9666667.
Then I multiply the width expressed in inches by 2.54 to get the relative value expressed in centimeters. I'd expect to have a value of 21.00 Centimeters for nWidthInCentimeters but instead I got less than half of that value.

Could you give me a hand and tell me what am I doing wrong, please ?


Top
 Profile  
Reply with quote  
 Post subject: Re: [DynaPDF] Working with centimeters and inches
PostPosted: Sun Jan 18, 2009 2:19 pm 
Offline

Joined: Sat Oct 01, 2005 5:28 am
Posts: 226
Location: France
Resolution and size is not same thing:

if width = 595 points / 72 (dot per inch) = 8.264 inches * 2.54 = 20.99 cm
and at 72 dpi width = 595 pixels
if pict = 595 points width and 150 dpi resol. => 150/72=2.084 * 595 pixels = 1240 pixels (595pt at 150dpi)
size in cm is still 21, but with 2,084 time more pixels when printed.

but if you sample the pict to 595px final, at 150dpi resolution, size is 595pt/2,084=285pt=10,40cm

_________________
RS 2010r32- PPC MacOSX5.8


Top
 Profile  
Reply with quote  
 Post subject: Re: [DynaPDF] Working with centimeters and inches
PostPosted: Sun Jan 18, 2009 4:13 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Hi,

SetResolution is for embedded images only.
The points are always 72 dpi.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: [DynaPDF] Working with centimeters and inches
PostPosted: Mon Jan 19, 2009 9:23 am 
Offline

Joined: Fri Mar 09, 2007 2:04 am
Posts: 92
Location: Venice, Italy
Ah, now I understand. Thanks to both of you


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group