Jagand Posted October 5, 2012 Share Posted October 5, 2012 Is there a way I can know number of characters per line and number of lines that can fit into a page. My specific need is for page format 'Times New Roman' with A4 page format but I would like to know if there is a function in general that can help me with these details. My requirement is like this - write data into a document and when the number of characters written is large enough to fit a page, I must give a page break and write rest of characters to a new page and so on. I can write a custom function for this but the term "formatted printing" associated with function printf, sprintf tempted me to think that PHP might already have a function that does this task and that a new custom function would be unnecessary. One of the complexities with creating a custom function is that non Monospaced fonts such as 'Times New Roman' take different lengths for different characters Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Since the font is not monospaced, you cannot know the numbers of characters per line. You can fit many more "i"s into one line than "m"s. Quote Link to comment Share on other sites More sharing options...
Jagand Posted October 5, 2012 Author Share Posted October 5, 2012 Thank you. That is where things are looking complicated to me. Do you think its possible through PHP to determine the height of multitext data printed so far or use CSS to make a page look like its a new page when after certain height of text is printed? Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 There aren't really pages in the web in the same sense as print. Are you making a PDF? I don't understand what you're trying to do. Quote Link to comment Share on other sites More sharing options...
Jagand Posted October 5, 2012 Author Share Posted October 5, 2012 My intent is to create pages ready for printing and display to user a preview of the page to be printed. Please let me know if this clarifies. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 5, 2012 Share Posted October 5, 2012 Then you should generate a PDF. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.