![]() |
||
Home Products Purchase Downloads Demos Forums Blogs Ticket Wiki API Corporate |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.aspose.pdf.kit.AutoFiller
Represents class to recieve data from database or other datasource (eg. XML), fills them into the pre-designed fields of the template pdf and at last generate new pdf file(s) or stream(s). It has two template file input modes:input as a stream or a pdf file. It has four types of output modes:one merged stream, one merged file, many small streams and many small files. It can be used like this:
CASE 1: input file, output pdf file(s): AutoFiller autoFiller = new AutoFiller(columnName, dataSource); //uncomment the next line will produce a single big pdf file. //autoFiller.setGenMultiPdfs(false); //set input and output file names like this: autoFiller.setBasicPath("./examples/samplePdfs/"); autoFiller.setBasicFileName("output"); autoFiller.setInputFile("autoFillerTest.pdf"); //set a field which will keep unflattened like this: autoFiller.unFlatten("Name"); //fill data into the template like this: autoFiller.importData( ); //close the opened files and streams like this: autoFiller.close();CASE 2: input file, output multiple small pdf output streams: AutoFiller autoFiller = new AutoFiller(columnName, dataSource); autoFiller.setBasicPath("./examples/samplePdfs/"); autoFiller.setInputFile("autoFillerTest.pdf"); //initialize the output stream set like this: ByteArrayOutputStream[] outputs = new ByteArrayOutputStream[filesCount]; for (int i = 0; i < filesCount; i++) outputs[i] = new ByteArrayOutputStream(); //output streams will be put into outputs after close() autoFiller.setOutStreams(outputs); autoFiller.unFlatten("Name"); autoFiller.importData(); autoFiller.close();
CASE 3: here we test the methods, produce output stream(s). AutoFiller autoFiller = new AutoFiller(columnName, dataSource); autoFiller.setGenMultiPdfs(false); autoFiller.setBasicPath("./examples/samplePdfs/"); autoFiller.setInputFile("autoFillerTest.pdf"); FileOutputStream fileoutput = new FileOutputStream("test.pdf"); BufferedOutputStream output = new BufferedOutputStream(fileoutput); autoFiller.setOutStream(output); autoFiller.unFlatten("Name"); autoFiller.importData(); autoFiller.close(); output.close(); fileoutput.close();
Constructor Summary | |
AutoFiller(java.util.Vector fields,
java.util.Vector dataSource)
Represents a constructor of the AutoFiller object, two vector parameters should be provided. |
Method Summary | |
void |
close()
Close all streams to release related resources and write contents into outputs. |
java.lang.String |
getBasicPath()
The getter of the basicPath member. |
java.io.OutputStream[] |
getOutputStreams()
The getter of the output streams. |
void |
importData()
Automatically fill data into pre-defined template file and get file(s) output. |
boolean |
isGenMultiPdfs()
The getter of the genMultiPdfs member. |
void |
setBasicFileName(java.lang.String basicFileName)
The setter of the basicFileName member. |
void |
setBasicPath(java.lang.String basicPath)
The setter of the basicPath member. |
void |
setGenMultiPdfs(boolean genMultiPdfs)
The setter of the genMultiPdfs member. |
void |
setInputFile(java.lang.String inputFile)
The setter of the inputFile member. |
void |
setInputStream(java.io.InputStream inputStream)
The setter of the inputStream member. |
void |
setOutStream(java.io.OutputStream outStream)
The setter of the desStream member. |
void |
setOutStreams(java.io.OutputStream[] outputStreams)
The setter of the outputStreams member. |
void |
unFlatten(java.lang.String fieldName)
Specifies a field which will not be flattened in all the output file(s) or stream(s). |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AutoFiller(java.util.Vector fields, java.util.Vector dataSource)
fields
- A string object vector, containing the fields name of every field
to be filled.dataSource
- A composite vector object consist of serveral other vector objects,
each one contains a set of string values.Method Detail |
public void importData() throws java.lang.Exception
java.lang.Exception
- On error.public void unFlatten(java.lang.String fieldName)
fieldName
- The fully qualified field name.public void close() throws java.lang.Exception
java.lang.Exception
- On error.public boolean isGenMultiPdfs()
public void setGenMultiPdfs(boolean genMultiPdfs)
genMultiPdfs
- If need multiple outputs, set true; otherwise set false.public java.lang.String getBasicPath()
public void setBasicPath(java.lang.String basicPath)
basicPath
- A director name representing the working director, effecting
both input and output.public void setBasicFileName(java.lang.String basicFileName)
basicFileName
- The file name of output file or files, excluding the suffix (.pdf).
If genMultiPdfs = true, it will be automatically add a number to the end to produce
a series of output files, starting from 0.public java.io.OutputStream[] getOutputStreams()
public void setInputFile(java.lang.String inputFile)
inputFile
- The input file name containing the pre-defined template.public void setInputStream(java.io.InputStream inputStream)
inputStream
- An InputStream object containing the pre-defined template.public void setOutStream(java.io.OutputStream outStream)
outStream
- An OutputStream object containing the filled pdf stream.public void setOutStreams(java.io.OutputStream[] outputStreams)
outputStreams
- An OutputStream set containing the multiple filled pdf streams.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |