Django Render HTML to PDF | Introduction

Checkout my new Django Course!
dennisivy.teachable.com/p/dja...
Introduction to my next video on user django to render HTML templates in PDF format.
Source code: github.com/divanov11/django-h...
XHTML2PDF Documentation:

Пікірлер: 84

  • @nehat786
    @nehat7864 жыл бұрын

    Love your tutorials! Easy and very well explained

  • @DennisIvy

    @DennisIvy

    4 жыл бұрын

    Thank you! Glad you found them helpful :)

  • @jayshree9037
    @jayshree90373 жыл бұрын

    I think you are the best django teacher

  • @sriram9786
    @sriram97863 жыл бұрын

    Thanks exactly what I am looking for.

  • @jaelmaciel3899
    @jaelmaciel38994 жыл бұрын

    Thank you for sharing your knowledge! It was very useful for me.

  • @DennisIvy

    @DennisIvy

    4 жыл бұрын

    Glad the video helped! Thanks for your feedback :)

  • @sergeiklimov2029
    @sergeiklimov20294 жыл бұрын

    what should be on html template to render data in clean & in order

  • @abdelmfossa
    @abdelmfossa3 жыл бұрын

    Thank you Sir. It's work.

  • @manishkumar710
    @manishkumar7103 жыл бұрын

    Hey dennis, actually i was working on an e-commerce website as a project. Then i came across the feature to render invoice to pdf and send it through e-mail. And your video helped alot. So Thank you💐. Also, i wanted your little help. Actually i am unable to print product(s) details on pdf, it says "you are passing more than 1 object" when there is more than 1 product. It's the "orderItem" model, and it is based on your e-commerce website video. Will you please help me with this?

  • @nicko9958
    @nicko99587 ай бұрын

    Is there a newer/better tool than xhtml2pdf, cause it seems like this tool doesn't support lots of css features and is only made for very simple html pages. But for me it doesn't work with elements that have posiotion absolute or even a clip-path. Do you know a tool, that supports all css?

  • @xlsautomatizaciones9197
    @xlsautomatizaciones91973 жыл бұрын

    That works OK!! Thanks Dennis. I cant figure out how to attach the generated pdf to an email in order to send it . Anyone dealt with this? I would appreciate any help on this!

  • @hamzagt5
    @hamzagt53 жыл бұрын

    Heyyy, really awesome tutorials, definitely worth the effort, I was wondering if you can do pdf download onto the Django CRM tutorial, that would help alot!!! 😀

  • @valdinia-office2910
    @valdinia-office2910 Жыл бұрын

    Excellent video, thank you so much Dennis! What about the diacritics? When the HTML contains letters like ă,î,ș,ț,â I get this error: UnicodeEncodeError 'latin-1' codec can't encode characters in position 405-409: ordinal not in range(256)

  • @balabalaji6259
    @balabalaji62594 жыл бұрын

    Hi Bro. Awesome tutorials.! Could you please help to confirm is there way to open PDF file from desktop and extract specified field for 'n' number of PDF files in the folder via Django. I am trying to develop web app which can do PDF automation.

  • @alekszmaalmen7559
    @alekszmaalmen75592 жыл бұрын

    Thanks for overview! My actual css styles doesn't work despite i provide a function for 'link_callback' variable to define the path of css file which used in my template. Also i check this path and it's correct. But css styles doesn't work.

  • @lucasowino4239
    @lucasowino42393 жыл бұрын

    how do i write the data if its on my database.?

  • @souliphon_test3005
    @souliphon_test30054 жыл бұрын

    I have a problem. I was following this but this cannot display another language like Thai or Lao.

  • @saliksheraz6236
    @saliksheraz62363 жыл бұрын

    Thanks Alot Brother

  • @prakashandsons
    @prakashandsons3 жыл бұрын

    is there something like html2image or render_to_image, i want to render template to a image file and send via telegram api

  • @ibrahimkilic85
    @ibrahimkilic853 жыл бұрын

    First of all , Thanks. i have issue. i cannot view "ş, ğ, ı, İ etc." can you help me?

  • @zekict

    @zekict

    2 жыл бұрын

    Sorunu çözebildin mi? aynı dertten muzdaribim....

  • @rdarktemplar1989
    @rdarktemplar19893 жыл бұрын

    some syntax error, downloaded pdf has ' ' attached to it.

  • @ammarrady7430
    @ammarrady74304 жыл бұрын

    the problem is rendering images ( tried many different libraries but there is always an issue )

  • @Python_Hacks

    @Python_Hacks

    Жыл бұрын

    Any resolve?

  • @7even77
    @7even773 жыл бұрын

    What if we use pagination, is it real to print all the pages on pdf?

  • @copy4ever
    @copy4ever4 жыл бұрын

    Thank you for sharing

  • @DennisIvy

    @DennisIvy

    4 жыл бұрын

    My pleasure :)

  • @walidnewaz6475
    @walidnewaz64754 жыл бұрын

    Boss, how can i generate date wise sales report ?

  • @sergeiklimov2029
    @sergeiklimov20293 жыл бұрын

    Can you please advise what I should do to render cyrillic (russian) font on pdf page?

  • @ches_ter6842

    @ches_ter6842

    2 жыл бұрын

    Сергей, добрый день! Получилось ли решить вопрос с поддержкой кириллицы?

  • @nabinlama107
    @nabinlama1074 жыл бұрын

    brother thank you very much. I have a question that if i want to insert the data into invoice from database then how to code views function so that i can insert into invoice html file. could you please help me.

  • @tripathi5174

    @tripathi5174

    4 жыл бұрын

    Did you find any ways to do it sir???

  • @wethepeopleofghana8441

    @wethepeopleofghana8441

    4 жыл бұрын

    First query the database for the data you want, and then create a dictionary from it. The new dictionary will replace the static data dictionary that he has. Let me me know if you need help with that.

  • @alvarobencosme5348

    @alvarobencosme5348

    4 жыл бұрын

    @@wethepeopleofghana8441 i have a similar problem. I need a dynamic dictionary that depends the user selection. My problem is when going from one url[index] to another[function print], the variables change their value to None. you can help me pls?

  • @wethepeopleofghana8441

    @wethepeopleofghana8441

    4 жыл бұрын

    @@alvarobencosme5348 Yes, but I will have to see that part of your code. You can send me an email, aduemmanuelk21@gmail.com.

  • @wethepeopleofghana8441

    @wethepeopleofghana8441

    4 жыл бұрын

    @@alvarobencosme5348 I will be able to help, but I will have to see that part of your code. You can send me an email, aduemmanuelk21@gmail.com

  • @a.almakldi
    @a.almakldi3 жыл бұрын

    Need help please ... I did the same but unfortunately for it's printing scramble characters for Arabic characters ... Any one can help how to write Arabic characters to pdf.

  • @calebjebadurai
    @calebjebadurai3 жыл бұрын

    I want to create a multipage pdf with paragraph and table content. And the table may expand in rows thus making it multiple pages or a single page. I while doing this i also want to preserve the Header and Footer (both images). And I also want the liberty to be able to change the paper size. Default paper size = A4. Django + React

  • @samichosen524

    @samichosen524

    11 ай бұрын

    I'm looking to do that also, did u got any solution for that?

  • @fastc0de931
    @fastc0de931 Жыл бұрын

    Hi, how can you render an image in the pdf?

  • @dingli219
    @dingli2193 жыл бұрын

    Can you please add requirements.txt to your django projects?

  • @alphamusicbar
    @alphamusicbar4 жыл бұрын

    perfect

  • @computinginfo3187
    @computinginfo31874 жыл бұрын

    Dennis, may you please make a video on "csv files". Uploading and exporting them from a template with a table. Thanks!

  • @DennisIvy

    @DennisIvy

    4 жыл бұрын

    It might be a bit before I get to that but I'll add it to my recommendations list. Thanks for the input :)

  • @sharifahmed1925

    @sharifahmed1925

    4 жыл бұрын

    Yes please!

  • @mayankgupta6542
    @mayankgupta65423 жыл бұрын

    How to display model object images in pdf?

  • @swiftstand

    @swiftstand

    Жыл бұрын

    You need to get the user image.path

  • @rshnthms
    @rshnthms3 жыл бұрын

    Html won't use external css render to pdf? Any fix available?

  • @alekszmaalmen7559

    @alekszmaalmen7559

    2 жыл бұрын

    same issue, i provide a function for link_callback variable to perform the path of css file to an absolute path at my host machine, but css doesn't work.

  • @schoolive7977
    @schoolive79773 жыл бұрын

    Getting "unknown encoding: ISO-8859-1". PLZ HELP

  • @pranathikodicherla3283
    @pranathikodicherla32833 жыл бұрын

    The view button works perfectly for me but the download button is downloading a file of an unknown type. Thanks for the video :)

  • @techtips9512
    @techtips95124 жыл бұрын

    Hi thanks a nice video it helped me a lot. I want to get the template with its bootstrap designing but with this code its not working. another issue is the static images which are not loading. waiting for Response.

  • @safiullahkhansherzad7214

    @safiullahkhansherzad7214

    3 жыл бұрын

    for images. first of all you need to install pillow. secondly you need to do some setting inside the urls.py file which you can easily find on stackoverflow. just type static images not loading in django.

  • @iamavichayil
    @iamavichayil2 жыл бұрын

    Did you every actually make the HTML to PDF video u mentioned at the end??

  • @talgatv
    @talgatv3 жыл бұрын

    Спасибо бро

  • @tripathi5174
    @tripathi51744 жыл бұрын

    i am getting this error ModuleNotFoundError: No module named 'xhtml2pdf' even after installing

  • @amcpoland651

    @amcpoland651

    4 жыл бұрын

    not sure if its the issue but have you added it to your settings file?

  • @kaustubhgoyal4294
    @kaustubhgoyal42944 жыл бұрын

    Please share the HTML template for the pdf as well

  • @user-gi6gz9do3r
    @user-gi6gz9do3r4 жыл бұрын

    Спасибо. Есть ли возможность увидеть это на русском?

  • @what-the-code

    @what-the-code

    2 жыл бұрын

    Have u got solution? Plz share

  • @chetanrokade5156
    @chetanrokade51564 жыл бұрын

    @Dennis, I am getting below error while calling render_to_pdf function : Please help Request Method: GET Request URL: 127.0.0.1:8000/pdf_view/ Django Version: 2.1 Exception Type: gaierror Exception Value: [Errno 11001] getaddrinfo failed

  • @chetanrokade5156

    @chetanrokade5156

    4 жыл бұрын

    class ViewPDF(View): def get(self, request, *args, **kwargs): keypoints = KeyPoints.objects.exclude(KP_Flag='False') tick_list = Tickets.objects.exclude(Tick_Flag='False') monthlyActs = Monthly.objects.all().order_by('Remark') out_list = Outages.objects.exclude(Outage_Flag='False') # cr_list = CR.objects.all().order_by('CR_StartTime') cr_list = CR.objects.exclude(CR_Flag='False').order_by('CR_StartTime') context = { 'tick_list': tick_list, 'keypoints': keypoints, 'monthlyActs': monthlyActs, 'out_list': out_list, 'cr_list': cr_list, } pdf = render_to_pdf( 'Consolidated/consolidated.html', context) return HttpResponse(pdf, content_type='application/pdf') and in consolidated.html I m printing values as below for each dictionary : {% for KP in context.keypoints %} {{ KP.KP_Added_On }} {{ KP.Added_By }} {{ KP.KP_Description }} {% endfor %}

  • @shyamkariya9818
    @shyamkariya98184 жыл бұрын

    I want to save thi pdf in database how to do this

  • @angeldavid4514

    @angeldavid4514

    3 жыл бұрын

    I wanna do this too

  • @hamzagt5
    @hamzagt53 жыл бұрын

    Do you have course in udemy or anywhere?? I’d for sure attend ! And please could you render to pdf on the asset management app crush course, it will help a ton!!! I really hope you see this comment 🥺

  • @enrolmentaccount8713
    @enrolmentaccount87133 жыл бұрын

    Hi Dennis - great video, thanks for doing it. I tried using this code within an admin action to create pdfs 'with selected items..' but I can only download a pdf for the last item in the action's queryset. Have you any plans, or would you be interested, in doing a video for creating and downloading pdfs from an admin action?

  • @ayeshamunshi8043
    @ayeshamunshi80433 жыл бұрын

    Excellent work !!! Need one help. test Logo File is not able to see in the pdf, created a issue in git

  • @zekict

    @zekict

    2 жыл бұрын

    Did you find a solution? Actually, there are no problems with images when working on Windos, when I set up the project to run on Ubuntu, there is no image in the pdf file, although images appear on other pages.

  • @ayeshamunshi8043

    @ayeshamunshi8043

    Жыл бұрын

    @@zekict not so far

  • @paristar3079
    @paristar30794 жыл бұрын

    It is not able to render Js charts

  • @indrasuyut1958

    @indrasuyut1958

    3 жыл бұрын

    You can use var jp64 to download image (chart)

  • @digitaldata-surveying
    @digitaldata-surveying4 жыл бұрын

    I have problems with Arabic fonts

  • @what-the-code

    @what-the-code

    2 жыл бұрын

    Have u got solution? Plz share

  • @nabil.hamawi
    @nabil.hamawi3 жыл бұрын

    it's not working in any other language!!

  • @diescatric4559
    @diescatric45592 жыл бұрын

    does not support other languages I got something like Date: ■■■■■■ ■■■■ Amount: ■■■■■■■ ■■■ Bill to: ■■■■■■■ ■■■■■■■ ■■■ ■■■ any help please

  • @what-the-code

    @what-the-code

    2 жыл бұрын

    Have u got solution? Plz share

  • @mailtodanish
    @mailtodanish4 жыл бұрын

    Great ..But little Fast

  • @issamohammed3529
    @issamohammed35294 жыл бұрын

    how to show Arabic text ti pdf

  • @nabil.hamawi

    @nabil.hamawi

    3 жыл бұрын

    did you find the solution?

  • @what-the-code

    @what-the-code

    2 жыл бұрын

    Have u got solution? Plz share

  • @Name-pn5rf
    @Name-pn5rf4 жыл бұрын

    pdf is corrupted

  • @hamisomary539
    @hamisomary539 Жыл бұрын

    i'm lovely fun of you bro you

  • @komuisam6549
    @komuisam65493 жыл бұрын

    men por que hacen esto así mucho código engorroso toca ir a buscar una manera mejor mas corta importan de todos lados y algunas cosas no las muestras