weird textbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

kuzco
Forum Newbie
Posts: 7
Joined: Thu Jun 11, 2009 7:07 am

Re: weird textbox

Post by kuzco »

I want a4 size for it, not to change size, like I said- my letters to eat spaces and to stay like that. It doesn't have to be searhable. It's content has to be saved in database, when user come back to that page, that textbox have to stay like he left it.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: weird textbox

Post by omniuni »

Should the text be actual text, though, or are you wanting to save it as an image?

Remember, sizes on the web are not easily measured as they are elsewhere; can you specify a size in pixels instead?

How do you want a user to interact specifically? What size is the text? Can the user change font or font size or color?
kuzco
Forum Newbie
Posts: 7
Joined: Thu Jun 11, 2009 7:07 am

Re: weird textbox

Post by kuzco »

I want to save it as a text, which later I can change, delete etc. Well, let's say that textbox would be 80 x 80 pixels, I don't know how much is this. For font, font size and color, it's not important, I think if I make that textbox, I'll easily add some buttons, like in ms word. I think that that shouldn't be trouble. I'll start with text size 14, black Arial. And they can change it if they want. I would probably add the button for ordinary textbox, if user doesn't like this one, to change it. That's all.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: weird textbox

Post by mikemike »

For starters you need to learn about how dimensions work.

80 x 80 pixels is a tiny square. At a 300dpi resolution (correct for professional printing) an a4 piece of paper would be 2480 x 3408 pixels. Probably double the size of the majority of people's screens. So here you face another dilema, do you just display the full size page or do you minimise it for useability and then resize it later. But then you'll have issues with images.

If you want to store it as plain text I guess you'll have to work out a way of storing it in such a way that it's still editable. You could use the 'spaces' idea mentioned before and store this in a database, but then you'll have to work out exactly how many spaces fit onto a piece of paper. But then you have another problem. If you're not using a fixed-width font (which Arial is not) then you won't know how many characters is allowed. For example, I could fill the page up with the characters: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', in which case I could probably get a thousand or more on, or I may fill it up with 'WWWWWWWWWW', in which case I'd get considerably less, so how could you work with this? Maybe have an array with every character and it's width in pixels and work it out like that? But then what about when you hit the end of the line?

And now we have another problem. How can you word wrap? You can't use wordwrap() because it's not fixed width, so some lines may go over the width of the page and some may go drastically under. What if the user enters images? How would you display images? You can't have html because this is text.

I could go on all day about the amount of hassle this is bringing, not to mention how confusing it'll be for the user.

My advice. Go away and re-think what you're trying to do. There's probably a far easier way around it.

Some people here have mentioned using TinyMCE. That is a WYSIWYG HTML editor, so why not just use that? If you're printing (and I can only imagine that's what you're doing if it must be so much like a letter) then you can just play with the config of it to only allow certain heights and widths. If you're still having trouble you could create a HTML > PDF convertor or find one on the Internet, but you'll have issues showing this to the user in real-time as it's likely how it looks in TinyMCE will differ greatly than how it looks in a PDF.
Post Reply