Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Backend issues (#30) #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions resume/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
load_dotenv()

title = "Posts"
# Setting the correct path for configuration to wkhtmltopdf.exe
path_to_wkhtmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
Copy link
Owner

@DiptoChakrabarty DiptoChakrabarty Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this path would not work for linux users is there any way this can be supported for all Os.
Is there a reason to add the path , what does it accomplish?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest seems good , can you send the PR in the development branch from where I will merge to master , thats the flow I am adopting

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this path would not work for linux users is there any way this can be supported for all Os.
Is there a reason to add the path , what does it accomplish?

@DiptoChakrabarty when users download wkhtmltopdf, the configuration needs to be set up for the conversion to work. The pdfkit.from_string() function needs to be able to access the .exe application of wkhtmltopdf, else it will throw errors stating it couldn't find the PATH to the .exe file. That's why it is necessary to define the path to the .exe application and provide it as the input to the pdfkit.configuration() function, which is later used by the pdfkit.from_string() function.

Also, I searched on the internet, there's no option but to manually set the PATH up. I will still try searching for a solution, maybe I have missed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest seems good , can you send the PR in the development branch from where I will merge to master , thats the flow I am adopting

I will send in the PR after resolving two more bugs that I came across today. Mentioned in the Issue thread


@app.route("/")
def hello():
Expand Down Expand Up @@ -217,11 +219,13 @@ def downloadpdf():
image_file = url_for('static',filename='profiles/'+ current_user.image_file)
css = ["resume/static/resume.css","resume/static/main.css"]
rendered = render_template("resume.html",edu=edu,exp=exp,pro=pro,usr=usr,sk=skillsadded,achmade=achmade,image_file=image_file)
pdf =pdfkit.from_string(rendered,False,css=css)

# Configure wkhtmltopdf PATH via custom configuration
config = pdfkit.configuration(wkhtmltopdf=path_to_wkhtmltopdf)
options={'page-size':'A4', 'dpi':400, 'disable-smart-shrinking': '','enable-local-file-access': ''}
pdf = pdfkit.from_string(rendered,False,css=css,configuration=config,options=options)
response = make_response(pdf)
response.headers["Content-Type"] = "application/pdf"
response.headers["Content-Disposition"] = "attachement; filename=resume.pdf"
response.headers["Content-Disposition"] = "attachment; filename=download.pdf"

return response

Expand Down Expand Up @@ -314,7 +318,7 @@ def delete_exp(experience_id):
db.session.delete(expview)
db.session.commit()
flash('Your experience detail post has been deleted!', 'success')
return redirect(url_for('postexp'))
return redirect(url_for('postexperience'))


#Projects
Expand Down