Reputation: 896
I'm not sure if this question has been asked I've searched all over the net for about a week now and found nothing yet. I basically want to be able to create a pdf using fields from a form, now I wrote a similar servlet a while back where I used form data to write an email and I tried using similar principles but it didn't work. I'm not sure if I've missed a trick or completely misunderstood something but this is the code I wrote.
<%@
page import="java.io.*, com.itextpdf.text.*, com.itextpdf.text.pdf.*"
%>
<%
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("C:\\hello.pdf"));
document.open();
document.add(new Paragraph("Daily Briefing Sheet"));
document.add(new Paragraph(%><%request.getParameter("employeeid")%><%));
document.close();
%>
I can create the pdf but as soon as i use this line it won't create it.
document.add(new Paragraph(%><%request.getParameter("employeeid")%><%));
Upvotes: 0
Views: 1411
Reputation: 896
Made the rookie mistake of using another file that couldnt actually see the variables I was requesting because the button was going to a link not the form action destination
Upvotes: 0
Reputation: 1753
why use JSP tags within scriptlets? just remove the SCRIPTLETS and it should work
<%@
page import="java.io.*, com.itextpdf.text.*, com.itextpdf.text.pdf.*"
%>
<%
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("C:\\hello.pdf"));
document.open();
document.add(new Paragraph("Daily Briefing Sheet"));
document.add(new Paragraph(request.getParameter("employeeid")));
document.close();
%>
Upvotes: 1