Python terminal in html? - python

You can downvote this before you read (Edit:Thank you for understanding) because of the title but other questions just answers how to run python programs in html but what I want to do is use python terminal in html.
So guys there is actually big big question in my head. How exactly can I use python program in html like it is a terminal.
Here is my project, it will be an interactive dictionary that you can study on vocabulary.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial
}
* {
box-sizing: border-box;
}
/* The browser window */
.container {
border: 3px solid #f1f1f1;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/* Container for columns and the top "toolbar" */
.row {
padding: 10px;
background: #f1f1f1;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.scriptcontainer {
padding: 10px;
background: #ffffff;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.row2 {
padding: 5px;
background: #cc0000;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/* Create three unequal columns that floats next to each other */
.column {
float: left;
}
.left {
width: 15%;
}
.right {
width: 10%;
}
.middle {
width: 75%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Three dots */
.dot {
margin-top: 4px;
height: 12px;
width: 12px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
/* Style the input field */
input[type=text] {
width: 100%;
border-radius: 3px;
border: none;
background-color: white;
margin-top: -8px;
height: 25px;
color: #666;
padding: 5px;
}
.bar {
width: 17px;
height: 3px;
background-color: #aaa;
margin: 3px 0;
display: block;
}
/* Page content */
.content {
padding: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="column middle">
<h4><font size="6" type="Times">VocaDict</font></h4>
</div>
</div>
<div class="content">
<h3>=>Your dictionary:</h3>
<div class="row2"><div class="content"><div class="scriptcontainer"> <script>//This is where your dictionary will go!</script></div></div></div>
</div>
<div class="content">
<h3>=>Study lists:</h3>
<div class="row2"><div class="content"><div class="scriptcontainer"> <script>//This is where your dictionary will go!</script></div></div></div>
</div><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br>
</div>
</body>
</html>
What I'm asking is about this places:
<div class="content"><div class="scriptcontainer"> <script>//This is the place I want python terminal to be!</script>
I want this places act like a python terminal. When the page loads it will run the program, it will not affect any other thing and act like an independent thing but it will stay on the page and will be interactive.
Is that possible and If it is, how?
Thank you!

What are you trying to do here exactly? If you really want to run python script with HTML then go for CGI. As you can't run python directly you may have to use the below,
http://karrigell.sourceforge.net/en/pythoninsidehtml.html
or
http://www.skulpt.org/
But best way would be to use python-cgi programming https://www.tutorialspoint.com/python/python_cgi_programming.htm

It is impossible.
I had this question myself before. Clearly the intention was make room for other scripts, at least I think this way:
<script type="text/javascript">
<script type="text/python">
It would require a browser that implements this. Maybe this engine: https://www.gnu.org/software/pythonwebkit/

Related

Not Found: /style.css/ , django

I'm trying to create my own website on Django, but some problems stop me and I can't solve them myself.
I want to create a sidebar. I found a website with css and HTML code for it.
style.css:
#import url('https://fonts.googleapis.com/css?family=Montserrat:600|Open+Sans:600&display=swap');
*{
margin: 0;
padding: 0;
text-decoration: none;
}
.sidebar{
position: fixed;
width: 240px;
left: -240px;
height: 100%;
background: #1e1e1e;
transition: all .5s ease;
}
.sidebar header{
font-size: 28px;
color: white;
line-height: 70px;
text-align: center;
background: #1b1b1b;
user-select: none;
font-family: 'Montserrat', sans-serif;
}
.sidebar a{
display: block;
height: 65px;
width: 100%;
color: white;
line-height: 65px;
padding-left: 30px;
box-sizing: border-box;
border-bottom: 1px solid black;
border-top: 1px solid rgba(255,255,255,.1);
border-left: 5px solid transparent;
font-family: 'Open Sans', sans-serif;
transition: all .5s ease;
}
a.active,a:hover{
border-left: 5px solid #b93632;
color: #b93632;
}
.sidebar a i{
font-size: 23px;
margin-right: 16px;
}
.sidebar a span{
letter-spacing: 1px;
text-transform: uppercase;
}
#check{
display: none;
}
label #btn,label #cancel{
position: absolute;
cursor: pointer;
color: white;
border-radius: 5px;
border: 1px solid #262626;
margin: 15px 30px;
font-size: 29px;
background: #262626;
height: 45px;
width: 45px;
text-align: center;
line-height: 45px;
transition: all .5s ease;
}
label #cancel{
opacity: 0;
visibility: hidden;
}
#check:checked ~ .sidebar{
left: 0;
}
#check:checked ~ label #btn{
margin-left: 245px;
opacity: 0;
visibility: hidden;
}
#check:checked ~ label #cancel{
margin-left: 245px;
opacity: 1;
visibility: visible;
}
#media(max-width : 860px){
.sidebar{
height: auto;
width: 70px;
left: 0;
margin: 100px 0;
}
header,#btn,#cancel{
display: none;
}
span{
position: absolute;
margin-left: 23px;
opacity: 0;
visibility: hidden;
}
.sidebar a{
height: 60px;
}
.sidebar a i{
margin-left: -10px;
}
a:hover {
width: 200px;
background: inherit;
}
.sidebar a:hover span{
opacity: 1;
visibility: visible;
}
}
sidebar.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Responsive Sidebar Menu</title>
<link rel="stylesheet" href='style.css'/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<input type="checkbox" id="check">
<label for="check">
<i class="fas fa-bars" id="btn"></i>
<i class="fas fa-times" id="cancel"></i>
</label>
<div class="sidebar">
<header>My Menu</header>
<a href="#" class="active">
<i class="fas fa-qrcode"></i>
<span>Dashboard</span>
</a>
<a href="#">
<i class="fas fa-link"></i>
<span>Shortcuts</span>
</a>
<a href="#">
<i class="fas fa-stream"></i>
<span>Overview</span>
</a>
<a href="#">
<i class="fas fa-calendar"></i>
<span>Events</span>
</a>
<a href="#">
<i class="far fa-question-circle"></i>
<span>About</span>
</a>
<a href="#">
<i class="fas fa-sliders-h"></i>
<span>Services</span>
</a>
<a href="#">
<i class="far fa-envelope"></i>
<span>Contact</span>
</a>
</div>
</body>
</html>
All of these works if I start it in any snippet, or if I just run sidebar.html from pycharm in google, but when I start my site it doesn't work and gives an error: Not Found: /style.css/
Both files are on the same directory.
Easy fix, but you will need to dig into Django a bit more.
First, this tag <link rel="stylesheet" href=style.css/> will never work. The tag is written wrong on a few levels. The big problem is that the location is relative, the use of style.css is assumed to be on the same directory level as what ever page/script/etc is being called. The problem is that wsgi.py or similar file is actually the "root" that is "running" the site and has no idea where "style.css" exists and also deos not care.
Styles, image, js, etc are all stored as static assets in Django. This folder is "served" using a static tag that will transform to the correct path per your configuration for local dev and production. Take a look here: https://docs.djangoproject.com/en/3.1/howto/static-files/
I will not explain all the nuance, the Django site does a better job. Instead I will point out how Django is different from static sites or something like PHP. Django is an application running in the CGI (WSGI), there is only one "route" on the server so to speak, all data is served from this one file. PHP can and typically does serve data in a file+directory manner. In PHP/static scenario the location of files is stable compared to Django. In Django the page, url, and the way data is served all come from one point. That means the relationship to static files will be different and not something you can or should control.
Django does not want you to ever serve static files through the CGI (WSGI), that is a waste of CPU and resources and is slow for static. So they have a static system. When running locally with the configuration set up correctly and DEBUG=True then the static keyword will transform to the necessary local path in conjunction with your configuration.
When in production it is assumed that a CDN is used, in that case the static keyword is replaced with the path (URL) to the CDN static files.
The approach Django uses is much more mature than say, Wordpress where use of a CDN can be tricky (I have written custom CDNs for WP many times, not fun).
Walk through the link above, set up your configuration correctly and follow the rules. Django is very interested in your following of the rules, Deviation will only cause pain. I have been primarily a Django dev for almost 10 years now. The problem you ran into got me real good in the beginning, but now CDN and static file management is second nature and definitely more productive than other less mature systems.
Set static root on your 'settings.py'.
You're gonna want to change <link rel="stylesheet" href=style.css/> to <link rel="stylesheet" href="style.css"/>. Also, the path it is trying to find your style.css file in is like this: (whatever path to your sidebar.html)/sidebar.html/style.css. I doubt that it is located there. If it is located in the same directory as your sidebar.html file, try <link rel="stylesheet" href="./style.css"/>

CSS in Flask WTforms works on button but not for others

{% extends "layout.html"%}
{%block contents%}
<form method="POST" action="">
{{form.hidden_tag()}}
<div class="container">
{{form.username.label(class_="label-txt")}}
{{form.username(class_="label")}}
</div>
{{form.submit(class_="btn")}}
{%endblock contents%}
The above sign up page has submit button with the css which works fine but for the username field it is not working.
If i pass the same class for username it is working.
Very confusing, no CSS is working for the fields.
CSS:
.btn {
display: inline-block;
padding: 12px 24px;
background: rgb(220,220,220);
font-weight: bold;
color: rgb(120,120,120);
border: none;
outline: none;
border-radius: 3px;
cursor: pointer;
transition: ease .3s;
}
.btn:hover {
background: #8BC34A;
color: #ffffff;
}
.label-txt {
position: absolute;
top: -1.6em;
padding: 10px;
font-family: sans-serif;
font-size: .8em;
letter-spacing: 1px;
color: rgb(120,120,120);
transition: ease .3s;
}
.label {
display: block;
position: relative;
margin: 40px 0px;
}
.input {
width: 100%;
padding: 10px;
background: transparent;
border: none;
outline: none;
}
It looks you did everything right. The only thing that is causing a problem is your css on label-txt. Just take out position: absolute and see.
Assuming you have linked css file properly on your layout.html
url_for('static', filename='main.css'), you can see the class you added by inspecting the tag

selenium+python calls ie8 failed

I have searched the whole internet but didnt get the answer and even a similar onoe, so i decide to post here.
Enviroment:
windows7, python version 3.4, selenium version 3.7, IEDriverServer3.7.
the problem description is simple, I failed at this command
browser=webdriver.Ie()
and for 100% sure, I have downloaded the IEDriverServer.exe and the variable PATH has been appropriately modified to link to IEDriverServer.exe. And I have tested this linking by calling firefox instead of ie8 with geckodriver.exe in the same path as IEDriverServer.exe's. Undoutedly, it worked smoothly.
the whole passage of code is below:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import socket
DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings']=True
browser=webdriver.Ie();#selenium just stucked here
and the error report is here(it ended with a piece of html code):
Traceback (most recent call last):
File "C:/Users/nnceb/PycharmProjects/seleniumer/seleniumer.py", line 10, in <module>
browser=webdriver.Ie();
File "C:\Python34\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 82, in __init__
desired_capabilities=capabilities)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 165, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!--
body
{
font-family: "Microsoft YaHei", "宋体", "Segoe UI", "verdana", "arial";
background-image: url(http://www.netentsec.com/download/nps/squid_bg.jpg);
background-repeat: repeat-x;
background-color: #E8EAEF;
margin-top: 20px;
margin-left: 20px;
color: #575757;
}
a
{
color: rgb(19,112,171); font-size: 1em;
font-weight: normal;
text-decoration: none;
margin-left: 0px;
vertical-align: top;
}
a:link, a:visited
{
color: rgb(19,112,171);
text-decoration: none;
vertical-align: top;
}
a:hover
{
color: rgb(7,74,229);
text-decoration: underline;
}
p
{
font-size: 0.9em;
}
h1 /* used for Title */
{
color: #4465A2;
font-size: 1.1em;
font-weight: normal;
vertical-align:bottom;
margin-top: 7px;
margin-bottom: 4px;
}
h2 /* used for Heading in Main Body */
{
font-size: 0.9em;
font-weight: normal;
margin-top: 20px;
margin-bottom: 1px;
}
h3 /* used for text in main body */
{
font-size: 0.9em;
font-weight: normal;
margin-top: 10px;
margin-bottom: 1px;
}
h4 /* used for task links*/
{
font-size: 0.9em;
font-weight: normal;
margin-top: 12px;
margin-bottom: 1px;
}
h5 /* used for Heading in InfoBlock */
{
font-size: 1em;
font-weight: normal;
margin-bottom: 0px;
margin-top: 1px;
font-size: 0.9em;
color: #575757;
}
.actionIcon /* used for task link icons */
{
vertical-align: middle;
margin-top: 0px;
margin-right: 6px;
}
.infoBlock
{
padding-left: 25px;
font-size: 0.9em;
display: block;
line-height: 1.1 em;
color: #575757;
}
.errorCodeAndDivider
{
font-size: 0.7em;
font-weight: normal;
color: #787878;
}
ul, ol
{
font-size: 0.9em;
list-style-position: outside;
margin-top: 1px;
margin-bottom: 1px;
padding-top: 1px;
padding-bottom: 1px;
line-height: 1.3em;
}
.myul li{ list-style-type:none;}
.myul li{ background:url(http://www.netentsec.com/download/nps/s.gif) no-repeat 4px 8px; line-height:2.5em; padding-left:30px; font-family:"Microsoft YaHei", "宋体"; font-size: 0.9em;}
.divider
{
border-bottom: #B6BCC6 1px solid;
}
body
:lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }
:lang(he) { direction: rtl; }
--></style>
</head><body id=ERR_CONNECT_FAIL>
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>
<div id="content">
<p>The following error was encountered while trying to retrieve the URL: http://127.0.0.1:5555/session</p>
<blockquote id="error">
<p><b>Connection to 127.0.0.1 failed.</b></p>
</blockquote>
<p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>
<p>The remote host or network may be down. Please try the request again.</p>
<p>Your cache administrator is webmaster.</p>
<br>
</div>
<hr>
<div id="footer">
<p>Generated Fri, 17 Nov 2017 09:37:17 GMT by netentsec-nps-192.168.168.1 (nps/2.3.1)</p>
<!-- ERR_CONNECT_FAIL -->
</div>
</body></html>
Process finished with exit code 1
I use Ie8 to render the html code above get this page as below:
the html page
I have thought about this problem further, surposed it is because the port IEDriverServer uses as default is different to the one selenium uses for random. I open the IEDriverServer and everytime it shows it uses port 5555.
Open the IEDriverServer
So I modifed the source code to use port 5555 by default instead of randomo. However it does not work, with the same error report returned.

How to Use Splash (JS Rendering Service) with a Proxy

It's configured automatically in Scrapy, but not in Curl or normal request.
In curl, we can do this without any proxy:
http://<server_ip>:8050/render.html?url=http://www.example.com/?timeout=10&wait=0.5
How to do it with proxy?
I tried this:
http://<server_ip>:8050/render.html?url=http://www.example.com/?timeout=10&wait=0.5 --proxy myproxy:port
But I got:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Lightspeed Systems - Web Access</title>
<style type="text/css">
html {
background: #13396b; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzEzMzk2YiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzZTY1OTkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #13396b 0%, #3e6599 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#13396b), color-stop(100%,#3e6599)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #13396b 0%,#3e6599 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #13396b 0%,#3e6599 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #13396b 0%,#3e6599 100%); /* IE10+ */
background: linear-gradient(to bottom, #13396b 0%,#3e6599 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#13396b', endColorstr='#3e6599',GradientType=0 ); /* IE6-8 */
height: 100%;
}
body {
width: 960px;
overflow: hidden;
margin: 50px auto;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 14px;
color: #a2c3ef;
}
h1,h2 {
color: #fff;
}
h1 {
font-size: 32px;
font-weight: normal;
}
h2 {
font-size: 24px;
font-weight: lighter;
}
a {
color: #fff;
font-weight: bold;
}
#content {
margin: 20px 0 20px 30px;
}
blockquote#error, blockquote#data {
color: #fff;
font-size: 16px;
}
#footer p {
font-size: 12px;
padding: 7px 12px;
margin-top: 10px;
color: #fff;
text-align: right;
}
</style>
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
</head>
<body id=ERR_ACCESS_DENIED>
<div id="titles">
<h1>ERROR</h1>
<h2>Unable to complete URL request</h2>
</div>
<hr>
<div id="content">
<p>An error has occurred while trying to access http://<server_ip>:8050/render.html?.</p>
<blockquote id="error">
<p><b>Access denied.</b></p>
</blockquote>
<p>Security permissions are not allowing the request attempt. Please contact your service provider if you feel this is incorrect.</p>
</div>
<hr>
<div id="footer">
</div>
</body>
</html>
C:\Users\Dr. Printer>curl "http://<server_ip>:8050/render.html?url=http://www.example.com/?timeout=30&wait=0.5"
{"description": "Timeout exceeded rendering page", "type": "GlobalTimeoutError", "info": {"timeout": 30.0}, "error": 504}
If we want to use Crawlera as the proxy, we can do it using this lua script
function use_crawlera(splash)
-- Make sure you pass your Crawlera API key in the 'crawlera_user' arg.
-- Have a look at the file spiders/quotes-js.py to see how to do it.
-- Find your Crawlera credentials in https://app.scrapinghub.com/
local user = splash.args.crawlera_user
local host = 'proxy.crawlera.com'
local port = 8010
local session_header = 'X-Crawlera-Session'
local session_id = 'create'
splash:on_request(function (request)
-- The commented code below can be used to speed up the crawling
-- process. They filter requests to undesired domains and useless
-- resources. Uncomment the ones that make sense to your use case
-- and add your own rules.
-- Discard requests to advertising and tracking domains.
if string.find(request.url, 'doubleclick%.net') or
string.find(request.url, 'analytics%.google%.com') then
request.abort()
return
end
-- Avoid using Crawlera for subresources fetching to increase crawling
-- speed. The example below avoids using Crawlera for URLS starting
-- with 'static.' and the ones ending with '.png'.
if string.find(request.url, '://static%.') ~= nil or
string.find(request.url, '%.png$') ~= nil then
return
end
request:set_header('X-Crawlera-Cookies', 'disable')
request:set_header(session_header, session_id)
request:set_proxy{{host, port, username=user, password=''}}
end)
splash:on_response_headers(function (response)
if type(response.headers[session_header]) ~= nil then
session_id = response.headers[session_header]
end
end)
end
function main(splash)
use_crawlera(splash)
splash:init_cookies(splash.args.cookies)
assert(splash:go{{
splash.args.url,
headers=splash.args.headers,
http_method=splash.args.http_method,
}})
assert(splash:wait({0}))
return {{
html = splash:html(),
cookies = splash:get_cookies(),
}}
end
Don't forget to install scrapy-crawlera and activate it in the settings. For more information please refer https://support.scrapinghub.com/support/solutions/articles/22000188428-using-crawlera-with-splash-scrapy

xhtml2pdf child elements show border of parent elements

Hoping someone may have solved this problem. Haven't seen anyone with it on Google.
I'm using xhtml2pdf in Python, trying to generate a simple document with a header, footer and my content is blocks of text with titles. I'd like to have a border around each piece of content but instead I get borders around each child element instead.
Here's my HTML
#page {
size: letter;
border: 0;
#frame header_frame {
-pdf-frame-content: header;
border: 0pt solid white;
left: .75in;
width: 7in;
top: .5in;
height: 1.5in;
}
#frame content_frame {
border: 0pt solid white;
left: .75in;
width: 7in;
top: 1.5in;
height: 7.5in;
}
#frame footer_frame {
-pdf-frame-content: footer;
border: 0pt solid white;
left: .75in;
width: 7in;
top: 9.5in;
height: 1in;
}
}
h1 {
padding-top: 5pt;
}
.desc {
margin-top: 3px;
margin-bottom: 3px;
padding: 3px;
border: 1px solid blue;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>TEST TEST TEST</title>
</head>
<body>
<div id="header">
<h1>HEADER</h1>
</div>
<div id="footer">
FOOTER
</div>
<div class="desc">
<div class="title">TITLE OF ARTICLE</div>
<span>TEST 2</span>
<div>TEST 3</div>
<table>
<tr>
<td>Test4</td>
<td>Test 5</td>
</tr>
</table>
</div>
</body>
</html>
I'm just running the xhtml2pdf command line tool at the moment so there's no python to show. One thing I did notice when I run it in debug mode it shows "xhtml = false" even though I have an XHTML DTD. I'm not sure if this would make a difference.
Here's what I see in the browser and roughly what I expect the pdf to look like (ignoring the footer location of course):
Instead I get:
EDIT: I figured out that xhtml is an option to pass but passing it fails unless one has an old version of html5lib installed. Looks like the answer to my question is this library is not being actively maintained and I need to find a new solution :-/

Categories

Resources