8 Replies Latest reply: Feb 19, 2013 3:23 PM by George_Johnson RSS

    Dynamic Logo in PDF - Is it possible?

    Tore B. Krudtaa Community Member

      Hi

       

      I have earlier generated text field values in a PDF using a FDF file.

      The FDF file is generated using PHP on the server side.

       

      Now I need to do the same but I also need to be able to set a LOGO (image file) in the PDF dynamically (programatically).

      Is there a way to accomplish this using Acrobat XI PRO to make a PDF with the form fields needed?

       

      Perhaps using a hidden textfield value as the basis for the logo image. Then perhaps set the hidden textfield value same way the visible text fields get their value from the FDF file?

       

      It is important that this is working without the PDF viewer (person) not having to do anything to make the logo appear.

       

      It would be great if possible to do this using an FDF file. If not possible then I would like to hear if I can combine FDF with some other solutions.

       

      Any suggestions on how to make this work?

        • 1. Re: Dynamic Logo in PDF - Is it possible?
          George_Johnson CommunityMVP

          It's possible to include button appearances (or references to them) in an FDF. What will the source of the logo be? I'm trying to figure out if it can be a static image that can be retrieved from the server or if it will need to be generated dynamically, perhaps from a database, at the time of the request? Are you using some sort of API to generate the FDF?

          • 2. Re: Dynamic Logo in PDF - Is it possible?
            Tore B. Krudtaa Community Member

            I'm using PHP to generate the FDF file and to present the visitor with the correct PDF/FDF combination.

            The source of the logo will/can be an image (.jpg) file (from same server as the PDF is on). Was hoping to be able to use an URL pointing to the image to be used.

             


            I came across this document:

            How to load dynamic images in a PDF file using Adobe Reader/Acrobat 8+

            http://blogs.adobe.com/dmcmahon/2009/01/06/how-to-load-dynamic-images-in-a-pdf-file-using- readeracrobat-8/

             

            Some down in that document we can read:

             

            • Solution 2: Upload the images as attachments.
            1. Do one of the following to upload the images as attachments:
              • Use the attachment panel in Acrobat (View > Navigation Panels > Attachments > Add).
            2. Update the value of the image field using script at runtime to point to the attachment. (See the “Opening and saving attachments” section in the Javascript scripting guide)

             

            - Upload image through Javascript, by adding attachment (ref. Javascript for Acrobat).

            - Update the value of the image field using script at runtime to point to the attachment.

             

            Looking at the Javascript scripting guide as pointed to by the URL above, did not exactly show any good examples on how to do the above tasks.

            But it looks like it is doable.

            For this to work in my case I need to be able to make the javascript code load the correct image file.

            Which image file to load depends on which person is requesting the PDF and corresponding FDF file.

            Maybe it is possible to make the Javascript use a value transferred from the FDF file to the PDF file, or using another technique.

             

            Can someone here please explain to me how I do accomplish what is described above?

            • 3. Re: Dynamic Logo in PDF - Is it possible?
              George_Johnson CommunityMVP

              The technique discussed in that link is for an XFA form created in LiveCycle Designer that uses an image field, so it can't work with an Acroform.

               

              If you are able to convert the logos to PDF and make each page that is to be the source of a logo a template, you can simply include what is in essence a URL to the PDF on the server and include the name of the template you want to use. This is the simplest approach but it does mean the logos have to be prepared beforehand. If you were using the FDF Toolkit, you'd use the FDFSetAPRef method. If you'd like an example FDF that demonstrates this, I'd be happy to post one later.

              • 4. Re: Dynamic Logo in PDF - Is it possible?
                Tore B. Krudtaa Community Member

                Hi George and thanks for your reply

                 

                The end result of the PDF should be a one page PDF (one A4 page that is).

                If I can merge the LOGO-PDF with the other PDF into one PDF and still be able to use the corresponding FDF to fill out the PDF form fields then I'll be more than happy.

                 

                Basically I need LOGO-PDF to be on top, then the other PDF below.

                I also need this to work using the standard Acrobat reader (the free version).

                 

                Are you saying I can set the URL to the LOGO-PDF in the FDF? If that is the case... wohaaa.

                 

                If you could show me an example on how this is done it would be great.

                • 5. Re: Dynamic Logo in PDF - Is it possible?
                  George_Johnson CommunityMVP

                  I'll be able to send a sample FDF in a few hours. You will have to set up a button on the form where you want the logo to be paced and set its layout to something other than label only. You'll then need to prepare the PDF that contains the logo and make the page a template, giving it a name like "logo". I'd suggest using a separate PDF for each logo, as opposed to placing all of the logos in the same PDF, and set the template name of each the same. This will simplify the code that creates the FDF. Stay tuned...

                  • 6. Re: Dynamic Logo in PDF - Is it possible?
                    George_Johnson CommunityMVP

                    Here's a sample FDF:

                     

                    %FDF-1.2

                    1 0 obj <</FDF << /Fields 2 0 R >> >>

                    endobj

                    2 0 obj [

                    <</T(button1) /APRef << /N <</F(http://www.example.com/logo1.pdf) /Name(logo) >> >> >>

                    <</T(text1) /V (Hello) >>

                    ]

                    endobj

                    trailer

                    <</Root 1 0 R>>

                    %%EOF

                     

                     

                    In this example, the button that displays the logo is named "button1" and the PDF that contains the logo is given by that URL. The template name is "logo". I included a text field as well, which you're already familiar with.

                    • 7. Re: Dynamic Logo in PDF - Is it possible?
                      Tore B. Krudtaa Community Member

                      Thanks for that..
                      But what is the relationship between the template file and the name "logo".

                       

                      If I understand you correct then http://www.example.com/logo1.pdf is the PDF with the logo.

                      Where is the templatefile supposed to be stored, and will it in your example have to be named logo.pdf

                       

                      I thought there were two PDFs involved here:

                      - logo1.pdf with only the logo.

                      - template file with all the text fields

                       

                      Why no URL to the template PDF? Or is "logo" supposed to be changed with URL to template PDF?

                       

                      Will the button1 automatically be replaced with the logo1.pdf ?

                       

                      Will this work just using the two PDFs and the FDF, and Acrobat (the free version), or do I need any aditional software on the server to make this work?

                       

                      Could you please explain...

                      • 8. Re: Dynamic Logo in PDF - Is it possible?
                        George_Johnson CommunityMVP

                        A template is not a different file, think of it as the name of a page in the "logo.1.pdf" file. So you specify a page name as opposed to a page number. In Acrobat 9 you make a page a template and give it a name by selecting: Advanced > Document Processing > Page Templates

                         

                        and add a new one. In Acrobat 11 it's: Tools > Document Processing > Page Templates

                         

                        As I recommended earlier, for each logo, use a separate PDF but name the template for each the same.

                         

                        When the FDF is loaded, Acrobat/Reader will then fetch the page named "logo" from the PDF and use it as the appearance for the button. So you need three things: the PDF form, the FDF that the server generates, and a PDF containing the logo on the web server.