闪光印刷 - 镀铬省略精灵当印刷镀铬、闪光、精灵

2023-09-09 21:28:23 作者:暗似黛绿

快速摘​​要 我们有一个Flash应用程序(AS3),让用户阅读,互动和嵌入它的打印内容的能力。最近,我们注意到,从浏览器打印时,内容被略去,空白页打印(注意,空白页出现在浏览器的打印preVIEW以及)。我们看到这个问题与Chrome的版本21.0.1180.83(使用Flash版本 11.3.31.230 )。这是不可再现的任何其他浏览器。

Quick Summary We have a Flash application (AS3) that gives users the ability to read, interact and print content embedded within it. We've recently noticed that when printing from Chrome, content is omitted and empty pages are printed (note, blank pages appear in Chrome's print preview as well). We're seeing this issue with Chrome's version "21.0.1180.83" (using Flash Version "11.3.31.230"). This is not reproducible in any other browser.

技术细节 各内容页面psented作为雪碧再$ P $。为了正确地呈现内容,我们做了一些缩放/调整大小。为此,就需要使用位图。我们创建了一个新的BitmapData对象的(bMapData)并提请页面的精灵。我们采取的(bMapData),然后创建一个新的位图对象的(BMAP)它。最后,我们创建一个新的Sprite对象的(sObj)并添加(BMAP)作为其子。印刷(sObj)呈现空白页。

Technical Details Each page of content is represented as a Sprite. In order to render content properly, we do some scaling/resizing. We accomplish this with Bitmaps. We create a new BitmapData object (bMapData) and draw the page's sprite. We take (bMapData) and create a new Bitmap object (bMap) with it. Lastly, we create a new Sprite object (sObj) and add (bMap) as its child. Printing (sObj) renders blank pages.

我已经包括了一些样本code,可用于复制这样的:

I've included some sample code that can be used to reproduce this:

    private function printAsBitmap(sprite:Sprite):void{
        var bitmapData:BitmapData = new BitmapData(sprite.width, sprite.height, false, 0xffffff);
        bitmapData.draw(sprite);

        var bitmap:Bitmap = new Bitmap(bitmapData);

        var newSprite:Sprite = new Sprite();
        newSprite.addChild(bitmap);

        printSprite(newSprite);
    }

    private function printSprite(clip:Sprite) {

        var printJob:PrintJob = new PrintJob();
        var jobOptions:PrintJobOptions = new PrintJobOptions();     
        jobOptions.printAsBitmap=false;
        var numPages:int = 0;
        var printArea:Rectangle;
        var printHeight:Number;
        var printY:int = 0;

        if ( printJob.start() ) {

            /* Resize movie clip to fit within page width */
            if (clip.width > printJob.pageWidth) {
                clip.width = printJob.pageWidth;
                clip.scaleY = clip.scaleX;
            }

            /* Store reference to print area in a new variable! Will save on scaling calculations later... */
            printArea = new Rectangle(0, 0, printJob.pageWidth/clip.scaleX, printJob.pageHeight/clip.scaleY);

            numPages = Math.ceil(clip.height / printJob.pageHeight);

            /* Add pages to print job */
            for (var i:int = 0; i < numPages; i++) {
                //printJob.addPage(clip, printArea);
                printJob.addPage(clip,null,jobOptions);
                printArea.y += printArea.height;
            }

            /* Send print job to printer */
            printJob.send();

            /* Delete job from memory */
            printJob = null;

        }

    }

有没有人有一种变通方法的建议?

Does anyone have suggestions on a "workaround"?

任何及所有的帮助是AP preciated!

Any and all help is appreciated!

推荐答案

感谢您的文件,

我抓住了它,它就像我已经说过了 - 打印内容必须是在舞台上 - 以下是修饰你的打印方式:

I've grabbed it and it is like I've said - print content MUST be on stage - following is modified print method of yours:

private function print(clip:Sprite) {
        if (!clip) return;//safety

        var printJob:PrintJob = new PrintJob();
        var jobOptions:PrintJobOptions = new PrintJobOptions();     
        jobOptions.printAsBitmap=false;
        var numPages:int = 0;
        var printArea:Rectangle;
        var printHeight:Number;
        var printY:int = 0;

        if (stage)
            stage.addChild(clip);//add to stage for print


        if ( printJob.start() ) {

            /* Resize movie clip to fit within page width */
            if (clip.width > printJob.pageWidth) {
                clip.width = printJob.pageWidth;
                clip.scaleY = clip.scaleX;
            }

            /* Store reference to print area in a new variable! Will save on scaling calculations later... */
            printArea = new Rectangle(0, 0, printJob.pageWidth/clip.scaleX, printJob.pageHeight/clip.scaleY);

            numPages = Math.ceil(clip.height / printJob.pageHeight);

            /* Add pages to print job */
            for (var i:int = 0; i < numPages; i++) {
                //printJob.addPage(clip, printArea);
                printJob.addPage(clip,null,jobOptions);
                printArea.y += printArea.height;
            }

            /* Send print job to printer */
            printJob.send();

            /* Delete job from memory */
            printJob = null;

        }


        if (stage && stage.contains(clip))
            stage.removeChild(clip);//once done remove from stage

    }

当我已经修改了它,我能够有打印对谷歌,

when I've modified it I was able to have printout on google,

最好的问候