Stuart Jansen <sjansen <at> gurulabs.com writes:
Sorry Stuart I may sound stupid but I don't get it..
How your code will set meta info in existing PDF while using PdfCopy??? I'm not
trying to create brand new PDF, I just rename existing PDF and save it
somewhere, but I want this PDF have title as original doesn't have it.

-----------
PdfReader reader = new PdfReader(args[0]);
Map info = reader.getInfo();
int numberOfPages = reader.getNumberOfPages();
float newPageHeight = 8.5f * 72;
float newPageWidth = 7f * 72;

Document document = new Document(
        new Rectangle(newPageWidth,newPageHeight));
PdfWriter writer = PdfWriter.getInstance(document, 
        new FileOutputStream(args[1]));
writer.setPdfVersion(PdfWriter.VERSION_1_5);
document.addTitle((String)info.get("Title"));
document.addAuthor((String)info.get("Author"));
document.addKeywords((String)info.get("Keywords"));
document.setMargins(0, 0, 0, 0);
document.open();
-----------

My code is simple as this
-------------------------------
PdfReader pdfReader = new PdfReader("test.pdf");
Document document = new Document();
PdfCopy pdfCopy = new PdfCopy(document, new FileOutputStream("test2.pdf"));
document.open();
for(int i = 1; i < pdfReader.getNumberOfPages(); i++)
{
        pdfCopy.addPage(pdfCopy.getImportedPage(pdfReader, i));
}
document.close();
-------------------------------

Can you kindly provide explanaiton?



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to