8 Replies Latest reply on Sep 28, 2010 9:57 PM by Ruth E. Cruz

    jpg or pdf encoder flash

    flash search Level 1

      hi all,

      i just wanted know is it possible to encode jpg or pdf from flash in actionscript 2 ?just like http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from -flash/ this article.please tell me if it is possible and how?

       

      Thanks and regards

        • 1. Re: jpg or pdf encoder flash
          kglad Adobe Community Professional & MVP

          yes.  you can save a bitmap by looping through a bitmap's pixels in flash and save the string and loop through the string in server-side code and reconstruct the bitmap.  there's a pretty simple compression method from dmennonoh or you can use klingemann's bitmapexporter class.

           

          and you can use blazepdf to save a pdf.

          • 2. Re: jpg or pdf encoder flash
            flash search Level 1

            thank u for you reply.can u plz send me any kind of example or code regarding this.it will be helpfull for me.

            • 3. Re: jpg or pdf encoder flash
              kglad Adobe Community Professional & MVP

              it's too complex to explain but i can show you sample code for each.  which do you want to see?  or, better, check for help using google.

              • 4. Re: jpg or pdf encoder flash
                flash search Level 1

                please show me the sample code how to make .jpg and .pdf.

                 

                thanx

                • 5. Re: jpg or pdf encoder flash
                  kglad Adobe Community Professional & MVP

                  here's the code to copy and compress bitmap data:

                   

                  function PixelAF(bmp:BitmapData,number:Number):Array {
                      var num:Number = number-1;
                     
                      var h = bmp.height;
                     
                      // aStart = null assigned in sendDataToGatewayF when stepNum = 1;
                      if(aStart == null){
                          aStart = 0;
                      }
                      aEnd = Math.ceil(bmp.width*num/imageSlices);
                      //trace(aStart+" :PixelAF: "+aEnd);
                      var pixelA:Array = new Array();
                     
                      //for (var a = 0; a<=w; a++) {
                      for (var a = aStart; a<=aEnd; a++) {
                          for (var b = 0; b<=h; b++) {
                              var tmp = bmp.getPixel(a, b).toString(16);
                              pixelA.push(tmp);
                          }
                      }
                      aStart = aEnd+1;
                      return pixelA;
                  }

                   

                  function compressArray(orig:Array):Array {
                      var compressedA:Array = [];
                      var lei:Number = 0;
                      for (var i = 0; i<orig.length; i++) {
                          if (orig[i] != compressedA[lei]) {
                              compressedA[i] = orig[i];
                              lei = i;
                          } else {
                              compressedA[i] = "";
                          }
                      }
                      return compressedA;
                  }

                   

                  to create a pdf, check the documentation for blazePDF.

                  1 person found this helpful
                  • 6. Re: jpg or pdf encoder flash
                    Brad Aarron Level 1

                    Wow, I can hardly bear with these code ..  Why not convert PDF to Flash by this free online converter :http://www.axmag.com/submit.html

                    • 7. Re: jpg or pdf encoder flash
                      kglad Adobe Community Professional & MVP

                      because that's not dynamic:  you can't save something created during runtime using that.

                       

                      and, noone's trying to save a pdf as flash.  they're trying to saving graphics created in a swf during runtime.

                      • 8. Re: jpg or pdf encoder flash
                        Ruth E. Cruz

                        You should be able to use getURL("pdflocationhere.pdf"); - but I believe thats totally dependent on how the users computer is set up. If they don't have Adobe Reader, it will probably fail, or will attempt to load the pdf within a modern browser that should have the reader plug-in. From my experience, when using getURL() within a projector, it will attempt to open the filetype based on that specific filetype's default opening program which is set in the OS.