The “Web to Print” industry is very mature. You should be able to license what you require in an out of the box product that can be easily linked via an API to your website, or just rent a website that already does this (why reinvent the wheel).
A common solution licensed by many vendors is Aleyant’s eDocBuilder system which you can plug into your existing website/transactional shopping cart site via an API:
https://www.aleyant.com/page/edocbuilder
The eDocBuilder “engine" is also used in Aleyant's “out of the box” web to print website Pressero where no software development is required:
https://www.aleyant.com/page/pressero
If you wish to build it all yourself (reinventing the wheel, a black hole for time/money) and plug in a PDF generation library then I believe that the following ABCpdf library is also licensed and used by Aleyant:
ABCpdf - C# PDF Library Component for .NET
There are many others libraries and frameworks available. For example, you can license the Adobe PDF Library or you could create a solution by licensing Adobe InDesign Server technology. Try this link for more on various solutions for developers:
PDF SDK & PDF Developer Libraries
And many web to print vendors promote their products here:
Web-enabled Printing Systems - PrintPlanet.com
When you mentioned HTML this product also came to mind:
https://www.callassoftware.com/en/products/pdfchip
The caveat is “print ready” not all libraries are created equal, some may create RGB, CMYK and Spot Colour PDF files, however they may not support the overprint or multiply commands. So depending on your requirements they may still need some form of post processing preflight/fix etc.
Good luck!