Hi to all , ( sorry for my bad english )
how I can create, with a "ScrollAreaGadget" an A4 sheet? ( the monitor is not, of course, as big as an A4 sheet ...)
I will, (on this sheet virtual), able plug and move "StringGadget"
what I see, (in real proportions - A4) must be what then I'll print on paper (with PurePdf)
how can I calculate x / y of "StringGadget" to correctly position on A4 / Pdf?
Thank !
ScrollAreaGadget and A4 sheet
- VisualJump3D
- User

- Posts: 75
- Joined: Thu Jun 23, 2011 8:32 pm
- Location: italy
- Contact:
Re: ScrollAreaGadget and A4 sheet
First you need to get the dpi of the screen. Then I suggest to use Macros to translate mm to pixel and backwards. Here a very simple example, unfortunately Windows only:
edit: fixed an embarassing mistake... 
Code: Select all
dpi.l = GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #LOGPIXELSX)
Macro mm2px(mm)
Round(mm*dpi/25.4, #PB_Round_Nearest)
EndMacro
Macro px2mm(px)
Round(px*25.4/dpi, #PB_Round_Nearest)
EndMacro
OpenWindow(0, 0, 0, 600, 450, "A4 Sheet in Scrollarea", #PB_Window_MinimizeGadget)
ScrollAreaGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), mm2px(210), mm2px(297))
text.s = "This Text is placed 20 mm from the left and 35 mm from the top."
TextGadget(1, mm2px(20), mm2px(35), mm2px(40), mm2px(20), text)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindowStanley decided to go to the meeting room...
- VisualJump3D
- User

- Posts: 75
- Joined: Thu Jun 23, 2011 8:32 pm
- Location: italy
- Contact:
Re: ScrollAreaGadget and A4 sheet
Thanks !
Ps whats error ? <<edit: fixed an embarassing mistake... >>
and if i wont "translate" screen coordination of TextGadegt , for printing with pure pdf ?
Es x=gadgetY(1)
y=gadgetY(1)
Now, I want to printing in correct position (mm) to purepdf ( 25mm , 35mm ) on A4
(<<"This Text is placed 20 mm from the left and 35 mm from the top.">>
how do I convert?
Thanks to all
EDIT :
I'm idiot ....
is this :
Macro px2mm(px)
Round(px*25.4/dpi, #PB_Round_Nearest)
EndMacro
!!
Ps whats error ? <<edit: fixed an embarassing mistake... >>
and if i wont "translate" screen coordination of TextGadegt , for printing with pure pdf ?
Es x=gadgetY(1)
y=gadgetY(1)
Now, I want to printing in correct position (mm) to purepdf ( 25mm , 35mm ) on A4
(<<"This Text is placed 20 mm from the left and 35 mm from the top.">>
how do I convert?
Thanks to all
EDIT :
I'm idiot ....
is this :
Macro px2mm(px)
Round(px*25.4/dpi, #PB_Round_Nearest)
EndMacro
!!
Re: ScrollAreaGadget and A4 sheet
In the first version I put wrong calculations inside the macros, now it's fixed.VisualJump3D wrote:Ps whats error ? <<edit: fixed an embarassing mistake... >>
For printing it's more or less the same. You must know the dpi resolution of the output device (this time the printer), to know, how many pixels you need for one mm. Then you can convert the screen position to the position on the target. PureBasic provides the commands PrinterPageWidth() and PrinterPageHeight() to get the pixels of the client area. There are also sample codes in the forums. About PurePdf I can't say anything, because I haven't used it so far.
Stanley decided to go to the meeting room...
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ScrollAreaGadget and A4 sheet
In PurePdf, you can position your text etc in mm. However, if the info in the PDF file does not need to be editable, you can simply produce a screen-shot of the page and slap that into PurePdf.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: ScrollAreaGadget and A4 sheet
In that case you can use the macro above, like:IdeasVacuum wrote:In PurePdf, you can position your text etc in mm. [...]
Code: Select all
x = px2mm(GadgetX(1))
y = px2mm(GadgetY(1))Stanley decided to go to the meeting room...
- VisualJump3D
- User

- Posts: 75
- Joined: Thu Jun 23, 2011 8:32 pm
- Location: italy
- Contact:
Re: ScrollAreaGadget and A4 sheet
Re Thank to All!!