I've created an apparently valid document using a ByteArrayOutputStream.
The entire contents of this document are anchors with some text and links.
When I use PdfStamper to insert this document into an existing pdf file, the
anchors cease to function as anchors: only the anchor text seems to
transfer, not the URL and not their anchor-ish nature.
If I writeTo a FileOutputStream with the ByteArrayOutputStream, the
resulting file has the anchors and they function properly.
Below is the code where the problem presents, but the issue is back where
I'm creating the anchors?
All help appreciated,
Colin Freas
---
try {
// Set up article file name and "merged" name...
String mergeFileName = articleFileName.replaceFirst(".pdf$",
".merged.pdf");
FileOutputStream fos = new FileOutputStream(mergeFileName);
coverPdfOutputStream.writeTo(fos);
fos.close();
if (true)
return;
// Create PdfReaders for article file and for cover output
stream...
PdfReader articleReader = new PdfReader(articleFileName);
PdfReader coverReader = new PdfReader(coverPdfOutputStream
.toByteArray());
// Create PdfStamper which will manipulate existing article
pdf...
// TODO: change FOS to BOS and use BOS to overwrite existing
file!
PdfStamper mergedPdf = new PdfStamper(articleReader,
new FileOutputStream(mergeFileName));
mergedPdf.insertPage(1, PageSize.LETTER);
// Setup imported page to hold cover page...
PdfImportedPage coverPage;
// Use mergedPdf stamper object to get imported page from
reader...
coverPage = mergedPdf.getImportedPage(coverReader, 1);
// Get merge pdf "over" content...
PdfContentByte mergedContent = mergedPdf.getOverContent(1);
// Insert template with conent...
mergedContent.addTemplate(coverPage, 0, 0);
mergedPdf.close();
} catch
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/