After i modified source code, it can run but show some jun characters on
browser.
could you give me some advise on source doe?
MergePDFServlet.java:
....
ArrayList aList = new ArrayList();
String f1 = "c:\\share\\ChapterSection.pdf";
String f2 = "c:\\share\\SimpleAnnotations1.pdf";
aList.add(f1);
aList.add(f2);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Concatenate merge = new Concatenate(baos);
merge.mergePDF(aList);
baos.writeTo(rp.getOutputStream());
....
Concatenate.java:
.....
try {
int pageOffset = 0;
ArrayList master = new ArrayList();
int f = 0;
int count = 0;
count = filename.size();
//String outFile = "Merge.pdf";
Document document = null;
PdfCopy writer = null;
for ( f = 0;f < count;f++) {
// we create a reader for a certain document
System.out.println(f);
PdfReader reader = new PdfReader((String)(filename.get(f)));
reader.consolidateNamedDestinations();
// we retrieve the total number of pages
int n = reader.getNumberOfPages();
List bookmarks = SimpleBookmark.getBookmark(reader);
if (bookmarks != null) {
if (pageOffset != 0)
SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset,
null);
master.addAll(bookmarks);
}
pageOffset += n;
if (f == 0) {
// step 1: creation of a document-object
document = new Document(reader.getPageSizeWithRotation(1));
// step 2: we create a writer that listens to the document
writer = new PdfCopy(document,baos);
// step 3: we open the document
document.open();
}
// step 4: we add content
PdfImportedPage page;
for (int i = 0; i < n; ) {
++i;
page = writer.getImportedPage(reader, i);
writer.addPage(page);
}
PRAcroForm form = reader.getAcroForm();
if (form != null)
writer.copyAcroForm(reader);
//f++;
}
if (master.size() > 0)
writer.setOutlines(master);
// step 5: we close the document
document.close();
}
catch(Exception e) {
e.printStackTrace();
}
.....
Regards
Robin
_________________________________________________________________
Take a break! Find destinations on MSN Travel. http://www.msn.com.sg/travel/
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions