Passing iText created PDF back to Spring Framework

J

Jack

I'm building a paper application for auto insurance at the end of a
quoting process. The code is primarily a plug and chug type.
The PDF used as a template was built in Nitro PDF and contains
acrofields/forms.
The code thus far sets up a reader, stamper and writes the output to a
disk file. All of that works well.
Here is the code for the reader setup and main.

public class AutoApplicationPDFBuilder
{
private AssignmentDTO assignment;
private AutoQuoteDTO autoQuote;
private Document document;
private AcroFields form;
private PRAcroForm form2;
private Map hm;
private boolean isValetQuote = false;
private PdfReader reader;
private PdfStamper stamp;
private PdfWriter writer;
private ByteArrayOutputStream baos;

public void buildPDFDocument(PdfWriter pdfW, Document doc,
AutoQuoteDTO aQuote, boolean valetIndicator)
{
try
{
writer = pdfW;
document = doc;
autoQuote = aQuote;
isValetQuote = valetIndicator;
setUpReader(document);
loadApplicationFields();
stamp.setFormFlattening(true);
stamp.close();
}
catch (Exception de)
{
de.printStackTrace();
}
}

private void setUpReader(Document document)
{
try
{
//form filling demo
reader = new PdfReader("D:\\iText\\AutoApplication.pdf"); /*
get
from cache */
stamp = new PdfStamper(reader, new
FileOutputStream("D:\\iText\\Output.pdf"));
form = stamp.getAcroFields();

}
catch (Exception e)
{
e.printStackTrace();
}

}

The difficulty is returning the file built to the spring framework. I
have been able to replace the content of the buildPDFDocument method
with one to return a cirle in a PDF to spring and that works. I have
looked at a number of examples online using PdfStamper, PdfCopy, etc.,
but I've not successfully assembled all of the pieces. Your
assistance is very much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top