Hello.
Please help me in the followig questions;
How to;

  • Print a specific form.
  • To set custome header and footer.
  • Goto other page, enter data from previous page and trigger a specific button on next page.

Regards.

Dani AI

Generated

A compact, practical plan for printing the form and getting the header/footer you want (building on ’s suggestion to use a printer‑friendly view).

Create a dedicated print stylesheet and include any organization header (logo, address, phone) inside the page markup so it prints exactly where you want. Hide navigation, buttons and other UI with print rules and make the header visible only for print. Example CSS (put in a separate print.css or inside an @media print block):

@media print {
  .no-print { display: none !important; }       /* hide nav, buttons, etc. */
  .print-header { display: block; text-align:center; margin-bottom:8mm; }
  img.print-logo { max-width:200px; height:auto; }
  body { color:#000; background:transparent; }
}

Browser-supplied headers/footers (page title, URL, date/time, automatic page numbers) are controlled by the browser/print dialog and cannot be reliably set or removed from your HTML/CSS for every user. You can often ask users to turn off “Headers and footers” in print preview, and there are browser-specific hacks (like @page { margin: 0 }) that work in some engines, but they are inconsistent across browsers. (stackoverflow.com)

If you need absolute control (headers, footers, page numbers, identical output on all machines), produce a PDF on the server or with headless Chrome and send that to the user. Tools such as wkhtmltopdf and headless‑Chrome/Puppeteer let you inject precise header/footer HTML or templates and generate printable PDFs programmatically. Example (wkhtmltopdf): wkhtmltopdf --header-html header.html --footer-html footer.html input.html output.pdf. (wkhtmltopdf.com)

To carry data from one page to the next and trigger a button automatically: submit the data (POST or query string) or use sessionStorage/localStorage. On the second page, read the values on load, populate the inputs, then call document.querySelector('#targetButton').click() to trigger the action. Validate everything server‑side and test the print view in multiple browsers and print previews.

Recommended Answers

All 8 Replies

hi i am new here plz help me how to hide yor disk?

Ok, two things as both of you don't seem to have read the rules of Daniweb.

Firstly towards akkbkht, please can you show us what you have done so far so we know which bit you are stuck on specifically. Daniweb isn't designed for people to do your homework on. In response to your question however, you would need to be looking at JavaScript if you want to implement a function that allows a person to print a webpage from your site (others they can just do it in their browser, or pressing the Ctrl + P keys).

Secondly to Wesley.cheek.96, you should start a new thread if you have a question as to avoid people getting confused, and please include some more detail.

Thanks @AHarrisGsy.
I am creating a web based managment system. I want to facilitate the user with print button which will open the print dialogue box. But I want that I should set the header and footer according to my choice. So that user just press print button on web page then print button on print dialogue box.

Here is the code

<button type="button" onClick="window.print();" >Print</button>

Here is the sample print put page. I dont want the text "Patient Record | New Patient | Doctor Record | Medicine Record" at the top. Submit button and Logout button at the end. And I want to set the header and footer by default through html or php.
Thanks and Regrads

And yes. I would like to also print an image (which is not inserted yet) in the top area of the table. This image will be about the name of the organization and address plus contact numbers.
Thanks.

What you need to do is have it link to a printer friendly document, whether with the viewer knowing or without.

You can either do this by literally changing the page to one which includes what you want and doesn't include what you don't want, or you can change the CSS, print it and then change it back.

Good luck.

Still confused in the point.

I have printed a page on testing basis, it prints page title, and page address in header and page number lus date n time in footer. How can i control it. Please eleborate with an example.
Thanks.

Going back to my previous answer, you need to setup a printer friendly document. The JavaScript print function shall print the page in the same way as pressing Ctrl + P, which means anything that is seen on the screen shall be sent to the printer.
This means that you could be printing a very colourful, and thus expensive document which contains things you don't want as you've discovered.

To resolve this issue, you can do one of two things. When you click the button which shall print it you can either swap your CSS for one which removes the colours, and hides certain elements or you can copy the relevant data (such as the main article) onto a seperate HTML page and print that. Once you've sent it to the printer you are going to want to then redirect the browser back to the original page so that the user shall be none the wiser.

Does that make sense?

commented: Nice explanation +4

Got it. I have got for what I came here.
Thanks alot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.