Re: [iText-questions] PdfReader.getInfo returns null for Keywords

2016-03-14 Thread bhopB
I solved this issue. In case someone else find himself in the same position,
here is what I did. 
Here is the code:

PdfReader reader = new PdfReader(originalFile);

PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(tmpFileOriginal));

PdfStamper stamperOut = new PdfStamper(new 
PdfReader(tmpFileMergedFile),
new FileOutputStream(output));

stamperOut.setMoreInfo(stamper.getMoreInfo());
stamperOut.setXmpMetadata(reader.getMetadata());

stamper.close();
stamperOut.close();
reader.close();

Thanks.



--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfReader-getInfo-returns-null-for-Keywords-tp4661008p4661016.html
Sent from the iText mailing list archive at Nabble.com.

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231=/4140
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php


Re: [iText-questions] PdfReader.getInfo returns null for Keywords

2016-03-11 Thread bhopB
I wish to grab the metadata from the original Pdf and add it to the Pdf that
I modified using PdfCopy.

Thanks.



--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfReader-getInfo-returns-null-for-Keywords-tp4661008p4661013.html
Sent from the iText mailing list archive at Nabble.com.

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111=/4140
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php


Re: [iText-questions] PdfReader.getInfo returns null for Keywords

2016-03-11 Thread bhopB
Thanks for the reply. I am not using PdfStamper because I am loosing the
hyperlink hidden in the pages that I am adding on top of the original Pdf.
Here is the code merging both Pdfs.

public void concatenate(String firstFile, String secondFile, String output)
{

try {
// Step 1
Document document = new Document();
PdfReader reader;
PdfReader.unethicalreading = true;

// Step 2.
PdfCopy copy = new PdfCopy(document, new 
FileOutputStream(output));

// Step 2.5 Copying Pdf Properties.
reader = new PdfReader(secondFile);
HashMap map = reader.getInfo();

String title = map.get("Title");
String author = map.get("Author");
String subject = map.get("Subject");
String keywords = map.get("Keywords");
String creator = map.get("Creator");

if (title != null)
document.addTitle(title);
if (author != null)
document.addAuthor(author);
if (subject != null)
document.addSubject(subject);
if (keywords != null) {
document.addKeywords(map.get("Keywords"));
}

if (creator != null)
document.addCreator(creator+"/Forest Service");
else
document.addCreator("Forest Service");


// Step 3.
document.open();

// Step 4.
int n;
int page_offset = 0;
List listOfPdfs = new ArrayList();
listOfPdfs.add(firstFile);  // Pdf 
with Customed pages.
listOfPdfs.add(secondFile); // 
Original Pdf.

// Create a list for the bookrmarks
ArrayList> bookmarks = new
ArrayList>();
List> tmp;
 
// loop over the documents you want to concatenate
for (int i=0; i 0)
copy.setOutlines(bookmarks);

// Step 5.
document.close();

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

Thanks.


downloaded_SRS_34955.pdf
  



--
View this message in context: 

Re: [iText-questions] PdfReader.getInfo returns null for Keywords

2016-03-10 Thread nconde
I am adding new metadata with stamper

PdfReader reader = new PdfReader("ped.pdf");
PdfStamper stamper =
new PdfStamper(reader, new FileOutputStream("ped.pdf"));
HashMap info = reader.getInfo();
System.out.println(info.get("Keywords"));
System.out.println(info.get("Keywords"));
System.out.println(info.get("Keywords"));

info.put("Title", "Hello World stamped");
info.put("Subject", "Hello World with changed metadata");
info.put("Keywords", "iText nicolas conde");
info.put("Creator", "nicolas conde");
info.put("Author", "nicolas conde");
stamper.setMoreInfo(info);
stamper.close();

this code is full build



--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfReader-getInfo-returns-null-for-Keywords-tp4661008p4661011.html
Sent from the iText mailing list archive at Nabble.com.

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111=/4140
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php


Re: [iText-questions] PdfReader.getInfo returns null for Keywords

2016-03-10 Thread nconde
this is working for me 

PdfReader reader = new PdfReader("ped.pdf");
HashMap info = reader.getInfo();
System.out.println(info.get("Keywords"));


iText-2.1.7

plz send pdf and full code 

thanks!




--
View this message in context: 
http://itext.2136553.n4.nabble.com/PdfReader-getInfo-returns-null-for-Keywords-tp4661008p4661010.html
Sent from the iText mailing list archive at Nabble.com.

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111=/4140
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php