PrintJob printing background colour only
Hopefully someone can see something which I've missed out or something, because this is really odd! Basically I've created a print class which has all the print job code in to print a sprite, however when I print it, the sprite which I've created acts like a mask and the area where the sprite graphic should be is filled with my background colour.
So for example, my 100x100 black sprite looks like this in preview: http://www.willdonohoe.com/examples/print_job_fail.png
When I scale the image to the width and height of the print width and height, obviously I've got a page full of purple.
Anyway here's my code:
public function print():void {
//bitmap_to_print.smoothing = true;
var print_page:Sprite = new Sprite();
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0x000000, 1);
sp.graphics.drawRect(0, 0, 100, 100);
sp.graphics.endFill();
print_page.addChild(sp);
var print_job:PrintJob = new PrintJob();
addChild(print_page);
if (print_job.start()) {
trace(">> pj.orientation: " + print_j开发者_Python百科ob.orientation);
trace(">> pj.pageWidth: " + print_job.pageWidth);
trace(">> pj.pageHeight: " + print_job.pageHeight);
trace(">> pj.paperWidth: " + print_job.paperWidth);
trace(">> pj.paperHeight: " + print_job.paperHeight);
print_page.height = print_job.pageHeight;
print_page.scaleX = print_page.scaleY;
print_job.addPage(print_page);
print_job.send();
print_job = null;
} else {
//User does not have printer or user cancelled print action
}
removeChild(print_page);
}
If anybody has any idea, or had this problem before then any help will be greatly appriciated.
Many thanks,WillI just noticed that this thread isn't answered, and I forgot to say I found a fix. For some reason I needed to add the object I wanted to print directly to the stage, for example stage.addChild(movieclip), oddly it didn't seem to work if I added it in a child on the stage, it has to be added on the stage directly.
The good thing is, if you don't want the movieclip/bitmap/sprite to be shown when you print, if you set the visiblity to false, it will still print for you.
A bit of an odd one, but seemed to work.
Cheers, Will
精彩评论