|
|||
|
I've managed to print and printpreview some text and images.
But there's something not quit working when I'm printing a large text variable. When I reach the end of the page, the rest of the variable should be printed on the next page. But it doesn't. How can I make this work? Must I divide the var into two seperate vars? How do I know where to split the var? Or is there a function I can call to do this automaticly? |
|
|||
|
The developing edition of SWFKit at http://www.swfkit.com/download/swfkit.exe has the following two methods
1. getWrappedTextExtent(text, columnWidth[, tabstop[, wordwrap]]) Get the text extent that will be drawn in a column. The tabstop and wordwrap are two optional parameters. The tabstop parameter specifies the tab stop position, the default value is -1. The default value of wordwrap paramter is true. 2. printText2(text, left, top, width, height[, tabstop[, wordwrap]] Print text in a rectangle. The default value of tabstop is -1, the default value of wordwrap is true. If the text is too long to draw in the rectangle, the printText2 method will returns the remain charactors. Code:
var string = "";
for (i = 0; i < 26; i++)
{
for (j = 0; j < 3000; j++)
string += String.fromCharCode(65 + i);
}
var strToBePrinted;
Printer.onNewPage = function (page)
{
if (page == 1)
{
strToBePrinted = string;
this.continuePrinting = true;
return;
}
if (strToBePrinted == "") this.continuePrinting = false;
}
Printer.onPrint = function (page)
{ // put the image on the center of the paper
var width = this.pageWidth;
var height = this.pageHeight;
var font = new FontObject;
font.size = 12;
font.name = "System";
font.color = 0xFF0000;
this.font = font;
strToBePrinted = this.printText2(strToBePrinted, 0, 0, width, height);
}
Printer.printPreview();
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|