17 Replies Latest reply on May 7, 2009 5:26 AM by sudar1983_14

    Export JPEG

    Ken Krugh

      I'm working in CS3, Windows, VB. Can anyone tell me why this code won't produce a file?

       

      The only other thing I've tried is Ind.Selection(1).Export with these same parameters, which produces a file but only at 72 dpi, not a 900 dpi as I set in the JPEGExportPreferences.

       

          Set Ind = CreateObject("InDesign.Application.CS3")
          Set IDoc = Ind.ActiveDocument
          With Ind.JPEGExportPreferences
              .ExportingSpread = False
              .JPEGExportRange = idExportAll
              .JPEGQuality = idJPEGOptionsQuality.idHigh
              .JPEGRenderingStyle = idBaselineEncoding
              .PageString = "3"
              .Resolution = 900
          End With
          IDoc.Export idExportFormat.idJPG, "c:\jgpfile.jpg", False

       

      Thanks for the help,

      Ken

        • 1. Re: Export JPEG
          sudar1983_14 Level 2

          Hi,

           

          In CS3 there is no option to convert selected item to jpeg with preferences (CS3 bug)

           

          So, You have to resize the page to jpg size and then export with page as jpg.

           

          Regards,

          Sudar

          • 2. Re: Export JPEG
            Peter Kahrel Adobe Community Professional & MVP

            > In CS3 there is no option to convert selected item to jpeg with preferences (CS3 bug)

             

            That's not true: in CS3, in JavaScript, app.jpegExportPreferences.resolution = 300 works fine. Maybe it's a VB problem.

             

            Peter

            • 3. Re: Export JPEG
              sudar1983_14 Level 2

              Hi,

               

              Is it your code working fine then can you please send your code. I have a problem with my code.

               

              aDoc=app.activeDocument;

              selTextFrame=aDoc.pages.item(0).textFrames.item(0);

              app.jpegExportPreferences.resolution = 300;

              selTextFrame.exportFile(1246775072, "D:\\test.jpg", false);

               

              Regards,

              Sudar

              • 4. Re: Export JPEG
                Peter Kahrel Adobe Community Professional & MVP

                Your code works fine. What's your problem?

                 

                Peter

                • 5. Re: Export JPEG
                  Ken Krugh Level 1

                  No file gets produced. The only way I've been able to produce a file is by using the export command on the selection object. But THEN, the JPEG export preferences seem to be ignored.

                  • 6. Re: Export JPEG
                    Peter Kahrel Adobe Community Professional & MVP

                    > No file gets produced.

                     

                    Maybe you need a file object rather than a string. In JS you create a file object like this: File ('d:\\test.jpg'). I'd have expected that this was required in JS, but it worked on a simple string as well as on a file object. Maybe VB needs a file object.

                     

                    Peter

                    • 7. Re: Export JPEG
                      sudar1983_14 Level 2

                      Hi Peter,

                       

                      It is javascript code.

                       

                      It will produce a file, but the resolution is 72. Here the question is, it will support the preferences or not?

                       

                       

                      Regards,

                      Sudar

                      • 8. Re: Export JPEG
                        sudar1983_14 Level 2

                        Hi Ken,

                         

                        This is the code for VB, You have to set jpg size to the page and then export page as jpg then you get what you are expected.

                         

                        Here oFigureGroup is the selected item, oInDoc is the indesign document, olPg is the current page

                         

                        oFOGeo = oFigureGroup.GeometricBounds

                         

                        oPgHeight = oInDoc.DocumentPreferences.PageHeight

                        oPgWidth = oInDoc.DocumentPreferences.PageWidth

                         

                        oInDoc.DocumentPreferences.PageHeight = oFigureGroup.GeometricBounds(2) - oFigureGroup.GeometricBounds(0)

                        oInDoc.DocumentPreferences.PageWidth = oFigureGroup.GeometricBounds(3) - oFigureGroup.GeometricBounds(1)

                                        

                        oFigureGroup.GeometricBounds = oIPg.Bounds

                         

                        oIndsn.JPEGExportPreferences.Resolution = 300

                        oIndsn.JPEGExportPreferences.JPEGExportRange = idExportRangeOrAllPages.idExportRange

                        oIndsn.JPEGExportPreferences.PageString = oIPg.Name

                        oInDoc.Export idExportFormat.idJPG, "d:\test.jpg", False

                         

                        oInDoc.DocumentPreferences.PageHeight = oPgHeight

                        oInDoc.DocumentPreferences.PageWidth = oPgWidth

                                                       

                        oFigureGroup.GeometricBounds = oFOGeo

                         

                        Please let me know any other requires.

                         

                         

                        Regards,

                        sudar

                        • 9. Re: Export JPEG
                          SuperMacGuy Level 2

                          I had reported about 6 months ago that Applescript, on exporting selection, ignores the preferences. It was confirmed as a bug by an Adobe engineer, to me directly. I guess it also affects VB. As stated by another poster, you have to export the entire page to use the export preferences/dpi/quality/etc.

                          • 10. Re: Export JPEG
                            Peter Kahrel Adobe Community Professional & MVP

                            Well, JavaScript in CS3 and CS4, on Windows XP, exports the referenced text frame as expected, i.e. Sudhar's code works fine for me.

                             

                            Peter

                            • 11. Re: Export JPEG
                              SuperMacGuy Level 2

                              Ah OK, it's just an Applescript bug then. Thanks for (re) clarifying.

                              • 12. Re: Export JPEG
                                sudar1983_14 Level 2

                                Hi All,

                                 

                                In Javascript it will produce a jpg file, there is no doubt about it, but jpgpreferences are ignored, so resolution should be 72 only. It is actually Indesign CS3 bug.

                                 

                                 

                                regards,

                                sudar

                                • 13. Re: Export JPEG
                                  Peter Kahrel Adobe Community Professional & MVP

                                  Sudar,

                                   

                                  Again, you're wrong: Bridge and PhotoShop tell me that the JPEG of exported referenced frame (using the literal code you posted earlier) has the resolution set in the script. How do you determine the resolution of the exported file?

                                   

                                  Peter

                                  • 14. Re: Export JPEG
                                    Dave Saunders Level 4

                                    Peter,

                                     

                                    Where's your passion? Sudar is shouting very loudly. I wonder if you are being heard at all.

                                     

                                    Sardonic grin.

                                     

                                    Dave

                                    • 15. Re: Export JPEG
                                      sudar1983_14 Level 2

                                      Hi Peter,

                                       

                                      Im using Irfan view to see the resolution.

                                       

                                       

                                      Regards,

                                      sudar

                                      • 16. Re: Export JPEG
                                        AdobeScripts Level 3

                                        sudar1983_14 wrote:

                                         

                                        Im using Irfan view to see the resolution.

                                         

                                        ROTFL

                                        IrfanView isn't Maste-Of-All-Graphics-Applications

                                        so you should check your file in other applications before you shout so loud

                                         

                                        robin

                                         

                                        www.adobescripts.co.uk

                                        • 17. Re: Export JPEG
                                          sudar1983_14 Level 2

                                          Hi Adobe,

                                           

                                          This is my code,

                                           

                                          aDoc=app.activeDocument;

                                          selTextFrame=aDoc.pages.item(0).textFrames.item(0);

                                          app.jpegExportPreferences.resolution = 300;

                                          selTextFrame.exportFile(1246775072, "D:\\test.jpg", false);

                                           

                                          Plese find the attachment, ie exported jpg file.

                                           

                                           

                                          Regards,

                                          sudar