8 Replies Latest reply on Nov 3, 2008 1:58 PM by (nagrazr)

    Extracting/Setting PDF Table contents using javascript

      Hello,

      Can you experts please let me know the following?

      1. Is there a way to extract PDF table contents?
      2. Can I set the row value via java script?

      Bottom line is I need to implement editable table in PDF. What are the ways I can achieve this feat?

      Thanking you in advance!
      Best Regards
        • 1. Re: Extracting/Setting PDF Table contents using javascript
          Patrick Leckey Level 3
          Is this an XFA PDF or an AcroForm?
          • 2. Re: Extracting/Setting PDF Table contents using javascript
            Level 1
            Hi PDL,
            Thank you for the response!

            This is Acroform. If this can be achieved with XFA, I am still interested to know if this possible, if yes how?

            Thank you!
            Best Regards
            • 3. Re: Extracting/Setting PDF Table contents using javascript
              Patrick Leckey Level 3
              Then your question confuses me. How is the PDF being generated? Do you have a sample you can show us?

              If you're thinking of something like an Excel sheet that was printed to PDF, it's actually not possible because it isn't a table. It's simply data that has been visually arranged to look like a table. There are no rows or columns outside of the visual appearance - that's simply not how PDFs work.

              This is different with XFA - so again, you need to tell us how the PDFs are created and better yet provide a sample to look at.
              • 4. Re: Extracting/Setting PDF Table contents using javascript
                Level 1
                Hi PDL,
                I am actually writing a piece (C++) of code that generates Acroform currently. It is still in the primitive stage, just provided support only for text fields, choice fields and buttons.

                As I mentioned above, I have a requirement to generate a editable table...

                Sure I can provide the PDF(acroform) that is generated by the code.
                But how can I send the file to you? Can you share your email-Id? Or can I paste the content of the output here ?

                %PDF-1.5
                %%âãÏÓ
                1 0 obj
                <<
                /Pages 2 0 R
                /AcroForm 6 0 R
                /Type /Catalog
                >>
                endobj
                6 0 obj
                <<
                /CO []
                /Fields [ 7 0 R 9 0 R 10 0 R 11 0 R ]
                /NeedAppearances true
                >>
                endobj
                2 0 obj
                <<
                /Type /Pages
                /Count 1
                /Resources
                <<
                /ProcSet 3 0 R
                >>
                /Rotate 0
                /Kids [4 0 R ]
                >>
                endobj
                7 0 obj
                <<
                /A 8 0 R
                /BS <</W 1 /S /S>>
                /DA (/Helv 12.00 Tf 0.00 0.00 0.00 rg 0 G)
                /DR
                <<
                /Font <</Helv 14 0 R >>
                >>
                /F 4
                /FT /Btn
                /Ff 65536
                /H /P
                /MK
                <<
                /BC[0.87 0.83 0.55]
                /BG[1.00 0.94 0.55]
                /CA(PDF Button)
                >>
                /P 4 0 R
                /Rect [300.00 690.00 400.00 710.00]
                /Subtype /Widget
                /T (Button)
                /TU (PDF Button)
                /Type /Annot
                >>
                endobj
                8 0 obj
                <<
                /S /JavaScript
                /JS (if \(app.viewerVersion>=5\) {app.alert\("I-PDF 0.1 DEMO", 1\);})
                >>
                endobj
                9 0 obj
                <<
                /BS <</W 1 /S /S>>
                /DA (/Helv 12.00 Tf 0.00 0.00 0.00 rg 0 G)
                /DR
                <<
                /Font <</Helv 12 0 R >>
                >>
                /F 4
                /FT /Tx
                /Ff 12582912
                /H /P
                /MK
                <<
                /BC[0.00 0.00 0.00]
                /BG[1.00 1.00 1.00]
                >>
                /MaxLen 45
                /P 4 0 R
                /Rect [200.00 750.00 400.00 770.00]
                /Subtype /Widget
                /T (Text Field1)
                /Type /Annot
                >>
                endobj
                10 0 obj
                <<
                /BS <</W 1 /S /S>>
                /DA (/Helv 12.00 Tf 0.00 0.00 0.00 rg 0 G)
                /DR
                <<
                /Font <</Helv 13 0 R >>
                >>
                /F 4
                /FT /Tx
                /Ff 12591104
                /H /P
                /MK
                <<
                /BC[0.00 0.00 0.00]
                /BG[1.00 1.00 1.00]
                >>
                /MaxLen 15
                /P 4 0 R
                /Rect [200.00 720.00 400.00 740.00]
                /Subtype /Widget
                /T (Text Field2)
                /Type /Annot
                >>
                endobj
                11 0 obj
                <<
                /DA (/Helv 10.00 Tf 0.00 0.00 0.00 rg 0 G)
                /DR
                <<
                /Font <</Helv 15 0 R >>
                >>
                /F 4
                /FT /Ch
                /Ff 67239936
                /MK <</BG[0.87 0.83 0.55]>>
                /Opt [[( )( )] [(AMX) (American Express)] [(CBL) (Carte Blanche)] [(DCL) (Diners club)] [(DSC) (Discover)] [(ENR) (EnRoute)] [(JCB) (JCB)] [(MSC) (Mastercard)] [(VIS) (Visa)]]
                /P 4 0 R
                /Rect [200.00 650.00 300.00 670.00]
                /Subtype /Widget
                /T (Choice)
                /Type /Annot
                /V (VIS)
                >>
                endobj
                4 0 obj
                <<
                /Parent 2 0 R
                /Annots [7 0 R 9 0 R 10 0 R 11 0 R ]
                /MediaBox [0 0 595.00 842.00]
                /Resources
                <<
                /ProcSet [/PDF /Text /ImageI /ImageC]
                >>
                /Contents 5 0 R
                /Type /Page
                >>
                endobj
                5 0 obj
                <</Length 26>>
                stream
                q
                BT
                36 806 Td
                ET
                Q
                0 0 m

                endstream
                endobj
                3 0 obj
                <<[/PDF /Text /ImageI /ImageC]>>
                endobj
                12 0 obj
                <<
                /BaseFont /Helvetica
                /Subtype /Type1
                /Encoding /WinAnsiEncoding
                /Type /Font
                >>
                endobj
                xref
                0 13
                0000000000 65535 f
                0000000016 00000 n
                0000000172 00000 n
                0000002016 00000 n
                0000001756 00000 n
                0000001942 00000 n
                0000000081 00000 n
                0000000272 00000 n
                0000000603 00000 n
                0000000709 00000 n
                0000001017 00000 n
                0000001326 00000 n
                0000002064 00000 n
                trailer
                <<
                /Root 1 0 R
                /Size 13
                >>
                startxref
                2162
                %%EOF
                • 5. Re: Extracting/Setting PDF Table contents using javascript
                  Patrick Leckey Level 3
                  Ah, if you want to generate an editable table on the fly you'd most likely want to look at XFA. The XFA Specification (current version is 2.7) is available from here:

                  http://partners.adobe.com/public/developer/xml/index_arch.html
                  • 6. Re: Extracting/Setting PDF Table contents using javascript
                    Level 1
                    Hi PDL,
                    Thank you very much!

                    But do you have an sample PDF file that has editable table in it ?
                    • 7. Re: Extracting/Setting PDF Table contents using javascript
                      Patrick Leckey Level 3
                      The "Adding and Removing Table Rows at Runtime" sample might help you.

                      http://www.adobe.com/devnet/livecycle/articles/AddingRemovingTableRows.pdf
                      • 8. Re: Extracting/Setting PDF Table contents using javascript
                        Level 1
                        Hi PDL,

                        Thank you very much for your help!

                        I will try to understand the example... Hope I will be able to achieve what I am trying to do.

                        But just out of the curiosity, the acroform or XFA form PDF file sizes are really big...

                        What is your opiinion on embedding the flex tables in to PDF documents? Will that be more efficient in terms of file size?