hi ,
This is santosh here.Actually i have to merge the pdf docs into one
pdf.before this i have to get the content from the database and inseerted
respective content into respective pdf dynamically by using pdfstamper
class and then i save that into one temprary folder.i repeat the same
process for all pdf documents.after this i tried to merge the pdfs which are
in temprary folder by using pdfcontentbyte and i got one single pdf
document.but in that document there is no data which i inserted before .
could u help me if possible with the solution.please send the solution to
this mail only,
The sample code is
public static byte[] MergeFiles(ArrayList sourceFiles)
{
Document document = new Document();
MemoryStream output = new MemoryStream();
try
{
// Initialize pdf writer
PdfWriter writer = PdfWriter.GetInstance(document, output);
//set our custom event to the pdf writer
writer.PageEvent = new PdfPageEvents();
// Open document to write
document.Open();
PdfContentByte content = writer.DirectContent;
// Iterate through all pdf documents
for (int fileCounter = 0; fileCounter < sourceFiles.Count;
fileCounter++)
{
// Create pdf reader
PdfReader reader = new
PdfReader(sourceFiles[fileCounter].ToString());
int numberOfPages = reader.NumberOfPages;
// Iterate through all pages
for (int currentPageIndex = 1; currentPageIndex <=
numberOfPages; currentPageIndex++)
{
// Determine page size for the current page
document.SetPageSize(
reader.GetPageSizeWithRotation(currentPageIndex));
// Create page
document.NewPage();
PdfImportedPage importedPage =
writer.GetImportedPage(reader, currentPageIndex);
// Determine page orientation
int pageOrientation =
reader.GetPageRotation(currentPageIndex);
if ((pageOrientation == 90) || (pageOrientation ==
270))
{
content.AddTemplate(importedPage, 0, -1f, 1f, 0,
0,
reader.GetPageSizeWithRotation(currentPageIndex).Height);
}
else
{
content.AddTemplate(importedPage, 1f, 0, 0, 1f,
0, 0);
}
}
}
}
catch (Exception exception)
{
throw new Exception("There has an unexpected exception" +
" occured during the pdf merging process.",
exception);
}
finally
{
document.Close();
}
return output.GetBuffer();
}
Thanking you.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
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/