Page 1 of 1

ScrollAreaGadget and A4 sheet

Posted: Sun Mar 29, 2015 9:26 pm
by VisualJump3D
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 !

Re: ScrollAreaGadget and A4 sheet

Posted: Mon Mar 30, 2015 8:47 am
by Karellen
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:

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_CloseWindow
edit: fixed an embarassing mistake... :cry:

Re: ScrollAreaGadget and A4 sheet

Posted: Tue Mar 31, 2015 11:53 am
by VisualJump3D
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

!!

Re: ScrollAreaGadget and A4 sheet

Posted: Tue Mar 31, 2015 12:30 pm
by Karellen
VisualJump3D wrote:Ps whats error ? <<edit: fixed an embarassing mistake... >>
In the first version I put wrong calculations inside the macros, now it's fixed.

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.

Re: ScrollAreaGadget and A4 sheet

Posted: Wed Apr 01, 2015 12:10 am
by IdeasVacuum
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.

Re: ScrollAreaGadget and A4 sheet

Posted: Wed Apr 01, 2015 8:38 am
by Karellen
IdeasVacuum wrote:In PurePdf, you can position your text etc in mm. [...]
In that case you can use the macro above, like:

Code: Select all

x = px2mm(GadgetX(1))
y = px2mm(GadgetY(1))
The idea with the screenshot is also not bad. This is great if you don't want people to edit or copy text inside the pdf. Printing results might be not so nice though.

Re: ScrollAreaGadget and A4 sheet

Posted: Wed Apr 01, 2015 8:49 am
by VisualJump3D
Re Thank to All!!