|
Gnostice PDFOne
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface defines a run-time event that can be used to
track/provide file names for documents generated by an overloaded
PdfDocument.split()
method.
import java.io.IOException; import com.gnostice.pdfone.PDFOne; import com.gnostice.pdfone.PdfDocument; import com.gnostice.pdfone.PdfException; import com.gnostice.pdfone.PdfNeedFileNameHandler; import com.gnostice.pdfone.PdfReader; public class PdfNeedFileNameHandler_Example implements PdfNeedFileNameHandler { static int fileCount = 0; // Activates the PDFOne.jar component static { PDFOne.activate("T95VZE:W8HBPVA:74VQ8QV:LO4V8", "9B1HRZAP:X5853ERNE:5EREMEGRQ:TX1R10"); } public static void main(String[] args) throws IOException, PdfException { // Read document passed in command line PdfReader reader = PdfReader.fileReader(args[0]); PdfDocument doc = new PdfDocument(reader); // Specify event handler that will provide a // new filename for each split document doc.setOnNeedFileName( new PdfNeedFileNameHandler_Example()); // Split the document doc.split(10); reader.dispose(); } // Provide a new file name for each split document public void onNeedFileName(PdfDocument d, StringBuffer fileName) { String oldFileName = fileName.toString(); fileName.delete(0, fileName.capacity()); fileName.append( "split_doc_" + (++fileCount) + "_with_pages_" + oldFileName + ".pdf"); } }
Method Summary | |
void |
onNeedFileName(PdfDocument d,
StringBuffer fileName)
Called by an overloaded PdfDocument.split()
method when it tries to save one of the split documents. |
Method Detail |
public void onNeedFileName(PdfDocument d, StringBuffer fileName)
PdfDocument.split()
method when it tries to save one of the split documents. User
classes implementing this interface can handle this event to
provide file names at run time.
d
- document that is being splitfileName
- name of the split document that is being saved
|
Pro. Ed. v5.0.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |