ScrollAreaGadget and A4 sheet

Just starting out? Need help? Post your questions and find answers here.
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

ScrollAreaGadget and A4 sheet

Post 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 !
Karellen
User
User
Posts: 84
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: ScrollAreaGadget and A4 sheet

Post 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:
Stanley decided to go to the meeting room...
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: ScrollAreaGadget and A4 sheet

Post 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

!!
Karellen
User
User
Posts: 84
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: ScrollAreaGadget and A4 sheet

Post 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.
Stanley decided to go to the meeting room...
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: ScrollAreaGadget and A4 sheet

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Karellen
User
User
Posts: 84
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: ScrollAreaGadget and A4 sheet

Post 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.
Stanley decided to go to the meeting room...
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: ScrollAreaGadget and A4 sheet

Post by VisualJump3D »

Re Thank to All!!
Post Reply