dcsimg
www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Script to Modify Print Page Setup

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    28

    Script to Modify Print Page Setup

    I'm looking for a way in JavaScript to be able to set the
    browsers "Page Setup" properties.

    I would like to be able to set the page margins.

    This is needed for printing purposes and not for displaying the page in the browser.

    I have a table that is 772 pixels in width that I need to
    print margins set at 0 so that it fits on the paper.

    Is this possible? Any other suggestions if not?

    Thanks for any help,

    SoupDogg

  2. #2
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    With CSS there is an option to do this, but is not supported by all the browsers if any.

    With IE you can use ActiveX controls.

    Eric

  3. #3
    Join Date
    Mar 2005
    Posts
    28
    Yeah I was messing around with the CSS last night with no success.

    Do you know where I can find an active x control to help me acheive this?

    Thanks

    Soupdogg

  4. #4
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    Adjust table width before printing....

    <HTML>
    <Head>
    <Style type='text/css' media='print'>

    #printSize {width : 670px}

    #printLink {display : none}

    </Style>
    </Head>
    <Body>
    <p> This is some other content at the top </p>
    <Table width='772' border='1' id='printSize'>
    <TR>
    <TD> This is a very wide table and this the text inside the only cell inside the sole row. The quick brown fox jumped over the lazy dog's back. The rain in Spain falls mainly on the plain.</TD>
    </TR>
    </Table>
    <p> This is some other content at the bottom </p>
    <a href=# onclick="window.print()" id='printLink'> Print this page</a>
    </Body>
    </HTML>

  5. #5
    Join Date
    Mar 2005
    Posts
    28
    That is a nice little piece of code. It wasnt exactly what I was looking for but I think it will work better and should solve my problem. I modified my code to hide my header table all pictures. My main display table is a two column table The first column 108px and the second is 662px. The 108px colum contains a picture/banner. So right now I have it set to just hide that picture. Is there anyway I can modify your code so it hides that entire row so that the big text column is completely left alligned when they print. Also the main text column has a 1px border is there anyway to hide this one print? Thanks for your help!

    Soupdogg
    Last edited by soupdogg; 03-25-2005 at 04:19 PM.

  6. #6
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    Give the TR an Id, and just like the others, include the #bigRow {display : none} in the style section. bigRow is an example, meaning <TR id='bigRow'>

  7. #7
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    I didn't notice your question about the border. Whatever Id you are using for the "main text", do the same, and set the border to none:

    Assuming the Id of the "main text" is "isMain"

    #isMain {border : none}

  8. #8
    Join Date
    Mar 2005
    Posts
    28
    Thanks a lot man. If I have any more torubles I will post again.
    Soupdogg

  9. #9
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    I re-read your immediatly preceding posts and you are variously using the terms row and column to mean the LEFT COLUMN, or the RIGHT COLUMN, correct?

    So, in that case, you would have to give each TD cell in a particular column the same Id, so that it would be hidden on print.

    If using the same Id for all cells, doesn't work, then you'll have to give each cell a unique Id, and go from there.

    But, you get the idea.
    Last edited by Warren86; 03-25-2005 at 04:54 PM.

  10. #10
    Join Date
    Mar 2005
    Posts
    28
    I got everything working except hiding that border.

    Actaully what I have is a two column one row table. In the right Column which is the main text there is another table. This table has the border on is as you will see below.

    <Style type='text/css' media='print'>

    #printSize {width : 475px}

    #nodisplayprint {display : none}

    #maintext {border : none}

    </Style>

    <td width="664" align="right" valign="top"><table width="662" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF" id="maintext">

    So I don't know why that wouldn't be working.

    Soupdogg

  11. #11
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    Try:
    {border: solid black 0px}

  12. #12
    Join Date
    Mar 2005
    Posts
    28
    Doesn't seem to be working?

  13. #13
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    You know what? In the table tag, where you set the border to 1, set it to 0. And then do this:

    <Table style='border: solid black 1px'>

    My thought is that CSS can't modify the hard coded border. So, use CSS to set it, and then use what I suggested previously to set it to none or 0px.

  14. #14
    Join Date
    Mar 2005
    Posts
    28
    that still doesnt work i guess i will jsut have to live with the border thanks for all of your help
    soupdogg

  15. #15
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    Okay, I may try other approaches over the next few days. If I solve it, I'll let you know. Take care.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles