PdfCopy only copies pages not other objects at a global level. Furthermore
only a single file can have fields, the other files must be flattened before
concatenating.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Sivasubramanian Gurunathan [SMTP:[EMAIL PROTECTED]
> Sent: Tuesday, September 16, 2003 12:48
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] Javascript are not getting copied in
> PDFCopy
> 
> Hi all,
> 
> I am using PDFCopy for merging PDF after mapping the
> fields using PDFStamper.
> 
> While opening the Merged Pdf, I am getting a script
> error, when I opened the form in Acrobat Editor 5.0.
> The detailed error is below.
> 
> ================================================
> Acrobat Database Connectivity Built-in Functions
> Version 5.0
> Acrobat EScript Built-in Functions Version 5.0
> Acrobat Annotations / Collaboration Built-in Functions
> Version 5.0
> 
> ReferenceError: CS_PDF_Util2_OnFormLoad is not defined
> ================================================
> Could anyone tell me how to prevent this error. I am
> not getting this error when I opened the merged pdf in
> Acrobat reader 5.0.
> 
> Herewith I am attaching the function I used for
> mapping values and merging pdf.
> 
> =================================================
>  public String
> PrintPDFDocumentUsingDataObject(String[]
> PDFFileArray,HashMap objHashMap) {
> 
>     //PDFGen pp = new PDFGen();
>     String lSFileInPdf = "";
>     String lSFileOutPdf = "";
>     String lSFinalOutPdf = "";
>     PdfReader objPdfReader = null;
>     PdfStamper objPdfStamper = null;
>     HashMap pdffields = null;
>     String lSKeyString = "";
>     ArrayList KeyArray = new ArrayList();
>     ArrayList PDFOPArray = new ArrayList();
>     try {
>       if (PDFFileArray != null && PDFFileArray.length
> > 0) {
>         for (int FileCount = 0; FileCount <
> PDFFileArray.length; FileCount++) {
>           lSFileInPdf = PDFFileArray[FileCount];
>           if(lSFileInPdf != null &&
> !lSFileInPdf.equalsIgnoreCase(""))
>           {
>           Log.print("Input File Path" + lSFileInPdf);
>           if (lSFileInPdf.indexOf(".pdf") != -1) {
>             lSFileOutPdf = lSFileInPdf.substring(0,
> lSFileInPdf.indexOf(".pdf"));
>           }
>           Date objdate = new Date();
>           long llDate = objdate.getTime();
>           //DateFormat objDateFormat = new
> SimpleDateFormat("ddMMMyyyy");
>           //lSDate = objDateFormat.format(objdate);
>           Log.print("TimeStamp" +
> Long.toString(llDate));
>           lSFileOutPdf = lSFileOutPdf +
> Long.toString(llDate) + ".pdf";
>           Log.print("Output File Path" +
> lSFileOutPdf);
>           PDFOPArray.add(lSFileOutPdf);
>           objPdfReader = new PdfReader(lSFileInPdf);
>          Log.print("Check --0");
>           if (objPdfReader != null) {
>             objPdfStamper = new
> PdfStamper(objPdfReader,
>                                    new
> FileOutputStream(lSFileOutPdf));
>             Log.print("Check --1");
>           }     
>           if (objPdfStamper != null) {
>             Log.print("Check --2");
>             AcroFields form =
> objPdfStamper.getAcroFields();
>             pdffields = form.getFields();
>             lSKeyString = pdffields.toString();
>             Log.print("KeyString" + lSKeyString);
>             KeyArray = GetKeys(lSKeyString);
>             for (int fieldcount = 0; fieldcount <
> KeyArray.size(); fieldcount++) {
>               String lsKey = (String)
> KeyArray.get(fieldcount);
>               String lSValue = "";
>             String lsKey1="";
>               if (lsKey != null &&
> !lsKey.equalsIgnoreCase("")) {
>                 //Log.print("INSIDE KEYCHECk");
>               Log.print(""+lSFileInPdf.lastIndexOf("/"));
>               Log.print("lSFileInPdf.indexOf(.pdf)
> ==="+lSFileInPdf.indexOf(".pdf"));
>               Log.print("Key Substring ==
> "+lSFileInPdf.substring(lSFileInPdf.lastIndexOf("/")+1,lSFileInPdf.toLower
> Case().indexOf(".pdf")));
>               String temp1 =
> lSFileInPdf.substring(lSFileInPdf.lastIndexOf("/")+1,lSFileInPdf.toLowerCa
> se().indexOf(".pdf")).toLowerCase();
>               Log.print("temp1 ==="+temp1);
>               Log.print("LSKEY =="+lsKey);
>               Log.print("LSKEY.indexof(temp1)
> =="+lsKey.indexOf(temp1));
>               lsKey1 = lsKey.substring(temp1.length()+2);
>               //lsKey1 = lsKey.substring(8);
>                 Log.print("lsKey1 = " + lsKey1);
>                 if (objHashMap.get(lsKey1.trim()) !=
> null) {
>                   lSValue = (String)
> objHashMap.get(lsKey1.trim());
>                   Log.print("lsKey" + lsKey);
>                   Log.print("lSValue" + lSValue);
>                  
> objPdfStamper.getAcroFields().setField(lsKey.trim(),
> lSValue.trim());
>                 }
>               }
>               //Log.print("lsKey" +lsKey);
>               //Log.print("lSValue" +lSValue);
> 
>             }
>           }
>           objPdfStamper.close();
>           objPdfReader = null;
>         }
>         }
>       }
>       if (PDFOPArray != null) {
>         Log.print("Check --3");
>         String out_pdffinal = "";
>         int n = 0;
>         PdfImportedPage page;
>         Document document = null;
>         PdfCopy writer = null;
>         PRAcroForm form;
>         for (int j = 0; j < PDFOPArray.size(); j++) {
>           String out_pdf = (String) PDFOPArray.get(j);
> 
>           if (j == 0) {
>             Log.print("Check --4");
>             Log.print("out_pdf" + out_pdf);
>             if (out_pdf.indexOf(".pdf") != -1) {
>               out_pdffinal = out_pdf.substring(0,
> out_pdf.indexOf(".pdf"));
>             }
>             Date objdate = new Date();
>             long llDate = objdate.getTime();
>             //DateFormat objDateFormat = new
> SimpleDateFormat("ddMMMyyyy");
>             //lSDate = objDateFormat.format(objdate);
>             Log.print("TimeStamp" +
> Long.toString(llDate));
>             out_pdffinal = out_pdffinal +
> Long.toString(llDate) + ".pdf";
>             Log.print("Output File Path" +
> out_pdffinal);
>             lSFinalOutPdf = out_pdffinal;
>             Log.print("Check --5");
>             Log.print("out_pdf" + out_pdf);
>             objPdfReader = new PdfReader(out_pdf);
>             n = objPdfReader.getNumberOfPages();
>           PdfDictionary dict = objPdfReader.getCatalog(); 
>           
>             document = new
> Document(objPdfReader.getPageSizeWithRotation(1));
>             writer = new PdfCopy(document, new
> FileOutputStream(out_pdffinal));
>           document.
>             document.open();
> 
>             Log.print("Check --6");
>             for (int i = 0; i < n; ) {
>               ++i;
>               page =
> writer.getImportedPage(objPdfReader, i);
>               writer.addPage(page);
>             }
> 
>             form = objPdfReader.getAcroForm();
>             if (form != null)
>               writer.copyAcroForm(objPdfReader);
> 
>             Log.print("Check --7");
>           }
>           else {
>             Log.print("Check --8");
>             objPdfReader = new PdfReader(out_pdf);
>             n = objPdfReader.getNumberOfPages();
> 
>             for (int i = 0; i < n; ) {
>               ++i;
>               page =
> writer.getImportedPage(objPdfReader, i);
>               writer.addPage(page);
>             }
>             form = objPdfReader.getAcroForm();
>             if (form != null)
>               writer.copyAcroForm(objPdfReader);
>             Log.print("Check --9");
>           }
>           File objFile = new File(out_pdf);
>            objFile.delete();
>         }
>         document.close();
>       }
>     }
>     catch (Exception e) {
>       e.printStackTrace();
>     }
>     Log.print("Done!");
>     return lSFinalOutPdf ;
>   }
> 
> ===================================================
> Can anyone tell me how to solve this issue?
> 
> Thanks and Regards,
> G.Siva.
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to