The location of any object in a given PDF is relatively random.
However, for your issue specifically - I don't see where you are
copying the metadata from one PDF to the other - you are just copying
pages.
Leonard
On Mar 10, 2008, at 6:20 PM, raybristol wrote:
>
> I have a simple function to extra some pages from a given pdf file
> to a new
> file which runs fine, however I need to save the meta data in the
> new file
> as well, if I open the original pdf file in a text editor I can see
> the meta
> data in the first few lines:
>
> %PDF-1.3
> %âãÏÓ
> 1 0 obj
> <<
> /Type /Catalog
> /Pages 2 0 R
>>>
> endobj
> 2 0 obj
> <<
> /Type /Pages
> /Kids [ 315 0 R 626 0 R 791 0 R ]
> /Count 252
>>>
> endobj
> 3 0 obj
> <<
> /ModDate (D:20080306065109-08'00')
> /DLI (2.0P1w \(Nt\))
> /OneWorldRelease (B7333)
> /CreationDate (D:20080306065024-08'00')
> /Name (R5642565)
> /Version (EMEAIR0001)
> /Author (ACROSBY)
> /BatchCreationDate (2008/3/6 6:50:23)
> /OWEnvironment (PD7333)
> /Machine (NACTX05)
> /Host (USNAENTOW)
> /Printer (\\\\usnaps21\\prt621bw01)
> /PDL#20Program (*JDE PCL)
> /DecimalSepChar (.)
> /ThousandsSepChar (,)
> /Language (English)
> /DateFormat (AOR)
> /NumberOfCopies (1)
> /DateSepChar (/)
> /Title (Print Invoices - UK)
> /Subject (Print Invoices - UK)
> /Producer (J.D.Edwards OneWorld \(B7333\))
> /Creator (Foster's Wine Estates)
> /Keywords (R5642565, EMEAIR0001, NACTX05, PD7333, \\\\usnaps21\
> \prt621bw01)
> /JobNumber (2031461)
> /FileName
> (J:\\jdedwardsoneworld\\ddp\\b7333\\PrintQueue\
> \R5642565_EMEAIR00_2031461\
> _PDF.pdf)
> /SystemInfo (fromOS 5 fromCP 1252 toOS 5 toCP 1252)
> /PageSize (VertSize 12240 HorzSize 15840, pageOrient 2)
> /PageInfo (lpi 205, cpi 38 DCFontSz 70)
> /Sect_0 (SN=Detail Line 1 Section;TP=GRP|CD;BV=V42565A;SI=2;PI=0)
> /Ctrl_0_0 (CN=Assoc Text - Header; CI=134; SI=2; TP=RV; DT=S;
> AL=RptVarObj;
> FS=145)
>
> However in the new generated file, if I open it in a text editor,
> the file
> start with:
>
> %PDF-1.4
> %âãÏÓ
> 3 0 obj <</Length 14001>>stream
> q 1 0 0 1 0 0 cm
> % OWObject (ON=RptConstObj; OT=RC; FS=30; SI=3; DT=S; OI=3; NO=1;
> NL=1;
> NF=0)
> BT
> /F1 1 Tf
> 1 i 1 w 10 M /DeviceRGB cs 0 0 0 sc /DeviceRGB CS 0 0 0 SC
> 7 0 0 7 258 583 Tm
> ... ...
>
>
> MyMethod: (note it can extrat the pages OK in a pdf viewer, but xI
> need the
> meta data as well which can be found using a text editor)
>
> public static void extractPDFPage(String fromPath, int from, int
> to, String
> toPath)
> throws AptoEnclosingException
> {
> log.info("Start extracting pdf file ...");
> try
> {
> PdfReader treader = new PdfReader(fromPath);
>
> int n = treader.getNumberOfPages();
> treader.close();
>
> PdfReader reader = new PdfReader(fromPath);
>
> if ((from < 1) || (n < to))
> throw new IOException("Required pages
> are out of range!");
>
> com.lowagie.text.Document document = new
> com.lowagie.text.Document(
>
> reader.getPageSizeWithRotation(1));
>
> File tempFile = new File(toPath);
> if (tempFile.exists())
> tempFile.delete();
>
> FileOutputStream outputFile = new
> FileOutputStream(tempFile);
> PdfSmartCopy copy = new PdfSmartCopy(document,
> outputFile);
>
> document.open();
> //I don't think meta[] is getting anything
> byte meta[] = reader.getMetadata();
> PdfStamper stamp = new PdfStamper(reader,
> outputFile);
>
> for (int i = from; i<to; i++)
> {
> PdfImportedPage page =
> copy.getImportedPage(reader,i);
>
> copy.addPage(page);
> }
> stamp.setXmpMetadata(meta);
>
> document.close();
> reader.close();
> log.info("Extracting pdf file done!");
> }
> catch (IOException e)
> {
> throw new AptoEnclosingException(e);
> }
> catch (DocumentException e)
> {
> throw new AptoEnclosingException(e);
> }
> }
>
>
>
> Many thanks for your help!!!
> --
> View this message in context: http://www.nabble.com/save-pdf-meta-
> data%2C-help%21-tp15950897p15950897.html
> Sent from the iText - General mailing list archive at Nabble.com.
>
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> 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/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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/