Guest User

Untitled

a guest
Jul 29th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Django output word files(.doc),only show raw html in the contents
  2. response = HttpResponse(view_data, content_type='application/vnd.ms-word')
  3. response['Content-Disposition'] = 'attachment; filename=file.doc'
  4. return response
  5.  
  6. <h1>some contents</h1>
  7.  
  8. <html>
  9. <head>
  10. <META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=UTF-8"">
  11. <meta name=ProgId content=Word.Document>
  12. <meta name=Generator content=""Microsoft Word 9"">
  13. <meta name=Originator content=""Microsoft Word 9"">
  14. <style>
  15. @page Section1 {size:595.45pt 841.7pt; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}
  16. div.Section1 {page:Section1;}
  17. @page Section2 {size:841.7pt 595.45pt;mso-page-orientation:landscape;margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}
  18. div.Section2 {page:Section2;}
  19. </style>
  20. </head>
  21. <body>
  22. <div class=Section2>
  23. 'Section1: Portrait, Section2: Landscape
  24.  
  25. [your text here]
  26.  
  27. </div>
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment