Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I create a PDF from a JSP using the PDF library (not the Report Generator)?

0
10 Posted

How can I create a PDF from a JSP using the PDF library (not the Report Generator)?

0
10

It is not recommended to create PDF’s from JSPs. JSP’s are intended to return text only, not binary content like PDF’s or images (for which you should use a Servlet). In more detail, a JSP page only has access to the PrintWriter, not the ServletOutputStream, so your response will be dependent on the encoding of the page. In addition, any newlines or spaces in your JSP will be inserted into your PDF, which as it’s a binary file is not a good idea. We’re not saying it can’t be done if you know what you’re doing and you’re careful, but whether it will work will depend on the browser, your application server and the environment it’s running in – so we don’t support it.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123