快速摘要
我们有一个闪存应用程序(AS3),它使用户能够读取、交互和打印嵌入其中的内容。我们最近注意到,当从Chrome打印时,内容被省略,空页被打印出来(注意,在Chrome的打印预览中也会出现空白页)。我们在Chrome的版本"21.0.1180.83“中看到了这个问题(使用Flash "11.3.31.230"). )这在任何其他浏览器中都是不可复制的。
技术细节
每一页内容都表示为雪碧。为了正确地呈现内容,我们进行了一些缩放/调整。我们用位图来完成这个任务。我们创建一个新的BitmapData对象(bMapData),并绘制页面的sprite。我们使用(bMapData)创建一个新的位图对象(bMap)。最后,我们创建了一个新的Sprite对象(sObj),并添加了(bMap)作为子对象。打印(sObj)呈现空白页。
我已经包含了一些示例代码,这些代码可以用来复制以下内容:
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;
}
}有人对“解决办法”有什么建议吗?
任何和所有的帮助都是感激的!
发布于 2012-09-07 11:21:07
谢谢你的文件,
我抓起了它,就像我说过的--打印内容必须在舞台上--以下是你修改的打印方法:
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
}当我修改它的时候,我可以在谷歌上打印出来,
诚挚的问候
https://stackoverflow.com/questions/12113403
复制相似问题