I want to create a pdf using wkhtmltopdf with different orientation(for eg: one page be portrait and another page be landscape and again portrait like that), i tried in css but it does not work.please help, thanks in advance.
my views.py
from django.views.generic.base import View
from wkhtmltopdf.views import PDFTemplateResponse
class pdf_view(View):
template = 'temp1.html'
filename = 'file1.pdf'
header_template='header_temp.html'
footer_template='footer_temp.html'
context= {'title': 'PDF GENERATION'}
def get(self, request):
response = PDFTemplateResponse(request=request,
template=self.template,
filename = self.filename,
header_template=self.header_template,
footer_template=self.footer_template,
context= self.context,
)
return response
my template.html
<html>
<head>
<meta charset="utf-8">
<title>{{ title }}</title>
<style type="text/css">
#landimg img{
margin-top:20px;
height:auto;
width:auto;
}
#portimg img{
height:auto;
width:auto;
margin-top:50px;
}
@page #port{
size:letter;
}
@page #land{
size:landscape;
}
</style>
</head>
<body>
<div id='port'>
<img src="/static/images/2_180_3.jpg" alt="" />
</div>
<div id='land'>
<img src="/static/images/land.JPG" alt="" />
</div>
</body>
</html>
@page css was not working while printing pdf, it was in portrait as default.