How to convert a html div to pdf [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hello I have an html page that through php pulls reports about sales and puts them in charts and graphs. It works great however I am looking for a way to convert a div box into a pdf so whoever is using the sight can print specific graphs and charts that are in selected div boxes. Is there a simple way to do this or is this unfeasible?
Thanks!

There are lots of answers here merely talking about making a PDF. That's the easy part - the hard part is finding an engine that renders the CSS well.
This question has been raised before, and the issue doesn't lie with feasibility (it's very possible and there are lots of solutions), but they vastly differ on their capabilities to translate CSS into PDF. Many just completely fail altogether.
From my research it looks like WKHTMLtoPDF is your best bet, as it uses a full WebKit engine to render the HTML first, then translate that into a PDF (I found a tutorial in addition to the docs).
The downside? It's command-line, so you'll need to engineer a solution involving either python or php to execute the program. Here's the PHP manual on executing a program.
Edit:
I have personally used FPDF before, which is a surprisingly light-weight solution with a caveat that you have to provide it with all of the HTML (edit:) line-by-line, rather than being able to use the browser-rendered result of a HTML page (a result that would include a rendered chart). I'm providing it merely as a suggestion and to help you work out where you can go from here, but it's not directly applicable to your complex CSS/chart problem.

Related

How can I create standard layout for multiple pages? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Currently, I am working on my first web page using HTML and CSS. I want to use the same layout like background and header etc but I can't find a way. Today I found a couple of website telling about the template. Is this the related to what I want to do.
Thank you for helping a beginner.
Sam
I would recommend you a few things:
Find websites that make you feel as it is what you wanted to build.
Check their source code and try to find the semantics they have maintained.
Once you figured it out, you should try to create similar one.
You should follow HTML5 specifications , as it will help you build solid foundation. while doing this you will also understand best practices.
HTML or designing mostly depends on requirements. so you might not get one rule to follow, just invest time understanding some great works out there and practice alot.
In case you are very concern to layout, search for website layout images and you will get plenty of images having typical elements like header, navigation/menu, body (left/right sub menu + main content), footer.
You can consider templates for learning but it may lead you to trap of copying-pasting.
You can use Microsoft Expression Web application, which handles template. You make one page and save it as template and declare editable parts for sites. Then You can create multiple empty HTML pages. Finally you attach template, then it works.
Or if you can use PHP, you can create different parts of your Web Site, like: header.php, footer.php, banner.php and include them in every page where modifying the body and not writing the same footer, header, banner

Create nicely designed resumé from info in database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I designed a nice resumé template in Sketch and now I want to make it available to use it for the users of a site.
The data will be stored in MySql database and the design should be modular depending on the information.
What is the best way of doing it? I though of replicating the design in CSS3 and then converting it with some of this scripts fpdf or mpdf but I don't thing that it's the easiest way of doing it.
What do you think?
Thanks!
An example of the resumé is the following:
If it's a set template/pattern I'd approach it like each segment as an object with a varying number of attributes based on data it returns from the mysql call.
IE when you pull the data from your table and start looping through a person's skills you can add that to the SKILLS object. Same for the Experience, etc etc.
Since this would essentially be like Parent Child nodes you could also do it with XML but the approach is really up to you.
You could then easily output the constructed resume as HTML (so your users on the site can see it live and may make changes, and then use a converter to convert to PDF (alots of languages have libraries to do just that). Most modern browsers can also already convert HTML pages to PDF too nowadays so you could also give them instructions on how to do that.
Just my two cents,
Hope it helps!

getting rid of redundant code between html pages [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I'm working on producing my own version of a web/db project my friend was given in school. This is my first project in either area and I'm still learning. Part of the project description mentions all of the pages the client wants. I'm solving this by making an unordered list of links to the different pages with appropriate labels. Complex, I know.
Then I realized that every page will have this. My question is this: is there a way to class certain portions of code in html, so I can just have a "navigation list" in each page, instead of the full code of the list and everything associated with it, in every page?
I want the code to be clean and efficient. That's my motivation in this question.
Your question provides little detail, but it sounds like you want something like a php include. If you are running your site on your local, change the .html files to .php and do <?php include('includes/navigation.php') ?> where includes/navigation.php is a path to JUST your navigation code.
What you are talking about is templates. You cannot do it in plain html... You would need to use a server side language like php. You could also do it with a JavaScript templating language like handlebars or similar, but not in plain html.
If you don't want to use PHP or some other server side technology for a simple menu, you can try various Javascript plugins like MenuCool.

How to display data from a file on website load? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
So I have a file that's already constantly being update on my server, but the directory currently isn't in my wwwroot folder until I can actually meddle around in there to get the directory to change.
So question #1 is if it's possible for my site to actually access this file away from the wwwroot? If not, it's okay. I'll find some way to get it in there.
This is however the more important part of this question. The file in question is currently in .data extension and contains a field such as {"cpu":30,"ram":300000}. It's been updated in real time with an application in the background, but how would I get my web page to pull those data and display it? I only started learning HTML and CSS several days ago, so my knowledge is still pretty limited here.
I cannot understand your first question. :S Please, could you be more clear?
For the second one, to read the text file you need a javascript code. You can do that as follow:
1º Open the file: file = fopen(getScriptPath("myFile.txt"), 0);
2º Get the content of the file in a string: file_length = flength(file); content = fread(file, file_length);
3º Finally, you can get the part of the string you want by a regex.
Pulling data from external sources and displaying it in HTML is a very common practice the purpose of programming languages like PHP. You aren't going to be able to do it with just HTML/CSS. Stick to static (unchanging) pages until you've got HTML/CSS down, and then you can learn a scripting language to make dynamic pages.

What's the easiest way to convert Wiki markup to HTML? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow.
What is the best way to convert ==Heading== to <h2>Heading</h2>, or --bold-- to <b>bold</b>? Can this be done simply with Regex, or does somebody have a simple function?
I'm writing this in C#, but examples from other languages would probably work.
It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanitise the input to ensure you don't create any cross site scripting vulnerabilities.
That said, you could probably do something pretty simple as you describe most easily with a regular expression replacement.
For example
replace the pattern ==([^=]*)== with <h2>\1</h2>
This really depends on the Wiki syntax you're using as there are several different ones. Obviously the wiki software has this functionality somewhere; if you can't find a software package that does this for you, you could start looking for the relevant code in your wiki software.
Maybe this is what you need.
This page is a compilation of links, descriptions, and status reports of the various alternative MediaWiki parsers — that is, programs and projects, other than MediaWiki itself, which are able or intended to translate MediaWiki's text markup syntax into something else.