Printing a page via a "Print" Button.

Discussion in 'HTML & Website Design' started by Matt Ridge, Sep 22, 2011.

  1. #1
    I am looking to find out if there is a way, since my book doesn't say squat about it, on how to print a page by using a "print button"... and also disallow some images from being printed when that button is pressed?

    Or is there a way to actually print data from a database from between date x to date y, and have it organized by not only date but an ID number?

    And doing all of this without using java, but CSS and PHP and SQL?

    Please don't just say yes, I am looking for resources that may be able to help me on my way, so if you can point me in the right direction it would be greatly appreciated
     
    Matt Ridge, Sep 22, 2011 IP
  2. ElectricChoice

    ElectricChoice Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hmmm, that's quite the tricky conundrum you have there. Although I don't get how you're wanting to apply this concept. At first it sounds like you want to print a web page by pressing the printer button, and skip images on the output. then you start talking about using php and css and such... can you clarify a little more please what you're trying to do exactly?
     
    ElectricChoice, Sep 22, 2011 IP
  3. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #3
    Nigel Lew, Sep 22, 2011 IP
  4. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Ok, here is the deal :)

    http://www.kaboomlabs.com/PDI/ncmr.html

    This site above is the dreamchild of me, with a lot of help from here tweaking and causing me to perfect this form so it looks nearly the same between Macs and PCs as well as multiple browsers including IE... this allows what is called a NCMR to be entered into a database.

    I want to take this form, and instead of using it for input of said data make it so that it will print out said data using the form as a template.

    What is going to happen is that someone is going to be entering in data for a quarter, (3 months). What I want to do is to be able to have it so that I can go in and either print a form showing an individual NCMR or a string of them through the quarter.

    What I don't want to have print out is the stickers/buttons. The Submit button and the XHTML tag... I realize I may have to create a new page without either of them on, which I have no issue doing, I just want to know if it is possible.
     
    Matt Ridge, Sep 22, 2011 IP
  5. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #5
    What you want is possible, just not without some scripting in Php, MySql, etc...

    You can create a second template in the "printed" style that you wish for it to be seen on paper, and simply fill out the form, hit submit and push the data to the template for printing... Which can be done all by hitting "submit".

    The process will have to be this...


    1 - form
    2 - form confirmation ( maybe, if you feel it is needed or not )
    3 - Print / create pdf for saving or whatever it is you want done.

    You have created your form... You need to create your "printed output" template then create a form processor to handle the data.

    Any and all data can be simultaneously inserted into a database, printed, shown, etc....

    The only curious statement you made is this part...

    You will need some php/myqsl, etc...
     
    workingsmart, Sep 22, 2011 IP
  6. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #6
    The PHP/SQL I'm not worried about, I want to keep this java and javascript free if possible. Less chance of hacking, etc...

    When you say step 3 though, that is what I need to know how to do..."creating a PDF" or at least a printable version.

    I also want to be able to have a search criteria before printing, as with the page I linked to I want to have multiple pages to print out at one time with the same format... Is that possible?
     
    Last edited: Sep 23, 2011
    Matt Ridge, Sep 23, 2011 IP
  7. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #7
    Are you trying to insinuate that JavaScript increases the chance of your files being hacked?...


    If you aren't worried about the php/mysql - then your question regarding the search functionality shouldn't need to be asked... You can write a search function before printing, although I don't see how you would have people fill out a form, to be printed, then search for more to print?...

    There are many ways to spit out a pdf via php... There are a few API's out there to that can be utilized for that purpose... Here's => http://www.fpdf.org/
     
    workingsmart, Sep 23, 2011 IP
  8. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #8
    Yes, Java as a whole has been proven in many cases to be insecure... that being said, the reason for the form is simple.

    The plebes enter in the data in the form, their manager wants to look up a form, he types in the form ID, and then is presented with said form. He also at times wants to look at a range of times, so for each instance is another page to print.

    That is what I am looking to do without java.

    I also want to create something that allows an admin to put in comments that also will be printed as well, so I have a few things I need to do.
     
    Matt Ridge, Sep 23, 2011 IP
  9. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #9
    You can do all of it with php/mysql/html/css - no javascript required at all...



    On a side note - Any scripting / programming language, if written poorly, is a security risk.
     
    workingsmart, Sep 24, 2011 IP
  10. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #10
    That is expected, hence why I am writing everything from scratch, and getting help here as I get stuck.
     
    Matt Ridge, Sep 26, 2011 IP
  11. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #11
    PEAR has both a pdf library and a spreadsheet library, so once you learn how the package you choose works, you can send the data to the user as either a spreadsheet or a pdf. (Depending on your coding skills, it should take between a day and a couple of months to learn a library well enough to use it.)

    What the user does with the resulting file is the user's choice - look at it, save it as a file, print it ...

    But what the user gets will be a spreadsheet you design or a pdf you design - not the original web page - so you don't have to worry about buttons, images, etc. And there's no Javascript or browser incompatibility. (Unless Redmond decides to break pdf compatibility in a future version of IE - just before declaring bankruptcy.)

    (I haven't used the pdf library, but the spreadsheet library is nice. I generate nicely formatted spreadsheets with it.)
     
    Rukbat, Sep 26, 2011 IP
  12. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #12
    You've seen the code I'm working on, I'm pretty much trying to make that into a sheet that is printable with the data already infused into it. What you have in mind sounds like an idea, but I'm not the admin of the webserver, and not sure how well they'd like to have pear on the system, especially a Windows SBS 2011...
     
    Matt Ridge, Sep 26, 2011 IP
  13. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #13
    It's just PHP. And remember, it's always easier to ask for forgiveness than for permission.
     
    Rukbat, Sep 26, 2011 IP
  14. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #14
    Permission for Java Applets, etc... Not simple JS that is used to handle things like error handling, form input validation and way beyond.

    Noone is suggesting that you run an ActiveX control or something so there is no permission to be granted by user / client.

    that being said, you can use php to print to a template that spits out a pdf, server side.

    As for admin being able to add comments, you'd use the output template to handle things like that while data is printed to the template for pdf creation.
     
    workingsmart, Sep 26, 2011 IP