3 Replies Latest reply on Jul 2, 2012 5:54 PM by jaloren28

    How do you control the PDF properties?

    jaloren28 Level 2

      I am creating a batch PDF processing script. The purpose is to generate PDFs from multiple books. Part of the script is supposed to set the PDF Setup options, such as whether to expand out the bookmarks and the default zoom level. However, I found that none of those settings are carried over into the PS file from which distiller generates the PDF.

       

      For example, here's some code that's supposed to set the expanded bookmark level to none:

       

      var Book = app.ActiveBook;
      if (Book.ObjectValid())
      {
          Book.PDFBookmarksOpenLevel=Constants.FV_PDFBookmarksOpenNoneLevel;
          Book.PrintFileName="C:\\Users\\jlorenz1\\Desktop\\PS_files\\in\\book.ps";
          Book.PrintToFile=true;
          Book.SilentPrintDoc();
          }

       

      However, when I generate the PDF from distiller, the bookmarks are still expanded out. I have also tried to set the PDF's default zoom level without any success.

       

      Has anyone had any success setting the PDF setup options from extendscript? If so, how did you do it?

       

      Thanks,

      Joe

        • 1. Re: How do you control the PDF properties?
          jaloren28 Level 2

          With some extremely helpful pointers from Rick Quatro, I believe I have more or less figured out how this has to be done. The script would need to do this:  1. in the FM book, save each file to MIF. 2. add/modify MIF statements in the file. 3. save the file back to the FrameMaker format.  For example, I have it figured out for the default PDF zoom level at least. I had to review the mif reference guide (could only find it for FM 8, any later guide out there?) and map that to the mif statements for FM 10 documents. They are similar to FM 8, but also slightly different. There's the following MIF document statements:               

           

          • <DPDFFit None>
          • <DPDFZoom  125.0%>

           

          In each document in the book, I need to set the above MIF statements. Then, the FM book will print the document to PDF, where the default zoom level is 125%.  A big thanks to Rick on this one.

          • 2. Re: How do you control the PDF properties?
            frameexpert Level 4

            Hi Joe,

             

            Actually, you may be able to set these properties directly without using MIF. The FrameScript versions are:

             

            Set oBook.PDFZoomType = PDFZoomNone;

            Set oBook.PDFZoomFactor = 1.25;

             

            where oBook is your book object. These properties can be set at the document level as well. The ExtendScript equivalents are:

             

            book.PDFZoomType = Constants.FV_PDFZoomNone;

            book.PDFZoomFactor = 1.25;

             

            I am not sure if 1.25 will work with ExtendScript. You may have to figure out how to coerce the number into the correct metric value.

             

            As far as saving to MIF, it is the .book file itself that has to be saved to MIF in order to set the correct bookmark levels for the paragraphs in the book. That is what the other thread referred to.

             

            I hope this helps.

             

            Rick

            • 3. Re: How do you control the PDF properties?
              jaloren28 Level 2

              Hi Rick,

               

              I cannot seem update the zoom level no matter what I do. Here's what I tried:

               

                 var Book = app.ActiveBook;

                  if (Book.ObjectValid())

                  {

                      Book.PrintFileName="C:\\Users\\jlorenz1\\Desktop\\PS_files\\in\\book.ps";

                      Book.PDFZoomType=Constants.FV_PDFZoomNone;

                      $.writeln('zoom factor before: '+ Book.PDFZoomFactor)

                      Book.PDFZoomFactor=125;

                      $.writeln(FA_errno)

                      $.writeln('zoom factor after: '+ Book.PDFZoomFactor)

                      Book.PrintToFile=true;

                      Book.SilentPrintDoc();

                      }

               

              According to the extendscript guide:

               

                   When the PDFZoomType property is set to Constants.FV_PDFZoomNone (0), the PDFZoomFactor property denotes the zoom percentage of the PDF document (metric 25% to 1600%).

               

              It also says the data type of the property is an integer. Here is the the default value: 81920. I have no idea where this number came from or what it is supposed to represent. When I attempt to set the PDF zoom factor to 125, that returns an error "number out of range". If I use a large number like 90,000, then it does update the property successfully but it doesn't change the default zoom level in the PDF. The PDF zoom level is always set to "Fit Width".

               

              Also, do you have any idea what this opaque statement is supposed to mean: (metric 25% to 1600%).  What in the world is a metric of a percentage, which is what that seems to be saying?

               

              Thanks,

              Joe