Help with real-life pdf project

Help with real-life pdf project


Hi everyone, thanks for reading.

In the real world, I have been asked to convert a page with complex tables into a pdf with a repeating header and pagination. The pages are generated with php and I have managed to capture them using obstart and obflush. I’ve even re-created the page in html using this output.

I have a couple apps I have looked at to convert the captured data into a pdf, with repeating headers, but most of them are lacking in instructions.

Additionally, I can’t figure out how to make a print button that runs the script on the current page, then brings up a print/save option for the generated pdf. Everything I see puts the script in the bottom of the page, then runs it when the page loads.

Also, I am thinking that the header, which itself is multiple tables and different on each page, should be converted to an image. The problem is, the last row of the header, is my table headers and needs to line up with the remainder of the page.

Any suggestions, ideas, pointers? Thanks!


While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:


Really what I need to know is If use, for example, html2pdf, how do I get the function to run only when the “print” button is pushed. Something like how the javascript print function prints the page.

Can you tell me which challenge would be best? I’ve already don 13 hours:HTML & CSS, Responsive Design with Bootstrap, jQuery and about 90% of Basic JavaScript (I’m up to Generate Random Whole Numbers within a Range.)

It’s not my program, and it’s not something I can put on codepen. It’s written in PHP mostly and Javascript, uses a handful of GitHub applications. It uses a basic javascript to print the page right now, but the client wants a precise layout.


Since Free Code Camp is primarily for teaching others to code, someone is more likely to help you out if you can post some code you have tried, but are not able to get to work. If you can show a more complete project of what you have (html, javascript, php), we could provide you some pointers, because we would be able to help other campers seeking to do something similar in the future. You stated you can not put the code on Codepen. You can put the html, css, and JavaScript on Codepen and put the php portion here as pasted code, unless it is huge. In that case, it would be best to post a link to a github resource for us to see.

When you say “get the function to run”, to which function are you referring?


Maybe stack overflow would be a better forum to ask this? Just my thought. I get my specific questions from there while general programming insight here. Maybe It will help to do some comparisons of the apps your talking about, that convert to the pdf. xyzToPDf vs atoBPDF. or reviews in google.
But like randel is saying We cant help much if: 1 you cant post the code your working on, and accurately describe what it is you’re trying to have accomplished. =(
With no context, its very easy to be misunderstood, and have a complete different answer to your original question.