How to convert a text (or html code) into pdf [closed]

I am building an app where you submit your resume, ChatGPT will tailor it based on a job description you also give and it will send back the resume as a tailored version, currently i just receive a text version. My goal is, to convert the text into a pdf file and send it in a resume form and there are a few problems with this,

  1. How am i able to format the text back into resume form, i cannot just send back the text but as a pdf file – A solution to this that i may have found is to get the AI to send back html code with styling and then convert html into a pdf using a library? but i looked into a lot of libraries and could not find one
  2. I have a feature that allows users to send their resume as a file, when i tailor it, i want to keep the same format as the file given, how can i do that logically?

I have been looking for a solution to this all day and i would really appreciate any help towards this.

Thank you!