Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 03-12-2004, 07:27 AM   #1
jcolletti
Registered User
 
jcolletti's Avatar
 
Join Date: Aug 2002
Location: Upstate New York
Posts: 52
Default How do I print the contents of a scrolling text field?

Greetings.
I'm populating a scrolling text field dynamically and I need to be able to send it's content to the printer on button press.

You would think that Flash would make this way too simple...something like myTextField_txt.print(); but of course it is not!

I've been monkeying around with the new MX2004 "PrintJob Class" with no success.

Based off the "Help" files this is the code I've come up with so far:

//Print Button
printText_mc.onRelease = function() {
var my_pj = new PrintJob();
var myResult = my_pj.start();
if (myResult) {
myResult = my_pj.addPage("scroller_txt", {xMin:0, xMax:400, yMin:400, yMax:800}, {printAsBitmap:false}, 1);
my_pj.send();
}
delete my_pj;
};
// End Print Button

Any help would be greatly appreciated.
jcolletti is offline   Reply With Quote
Old 03-15-2004, 07:30 AM   #2
jcolletti
Registered User
 
jcolletti's Avatar
 
Join Date: Aug 2002
Location: Upstate New York
Posts: 52
Default

Bump.
Sorry to be a post whore, but I'm deperate.
I got the PrintJob(); class to work - targeting a text field.
The problem is it will only print what's visable the the scroll area at the time of print. I need it to print the entire contents of the scrolling text field.

Any help would be greatly appreciated.
jcolletti is offline   Reply With Quote
Old 04-19-2004, 11:40 AM   #3
jayfour000
Registered User
 
Join Date: Apr 2004
Posts: 3
Default

:::Printing Multiple pages of a text box:::
Code:
on (click) {
//create PrintJob object
myPrintJob = new PrintJob();
//display print dialog box
myPrintJob.start();
var maxS:Number; //total number of lines in textArea
var botS:Number; //total number of lines visible in scroll box
//loop through untill i have added a page for each scroll pane
for (var i = 1; botS*i<=maxS; i++) {
// add specified area to print job
myPrintJob.addPage("_root.print_txta", {xMin:-36, xMax:612, yMin:-36, yMax:792}, {printAsBitmap:false});
maxS = _root.print_txta.label.maxscroll ;
botS = _root.print_txta.label.bottomScroll;
//manually scroll the box
_root.print_txta.vPosition = botS; 
}
// send pages from the spooler to the printer
myPrintJob.send();
// clean up
delete myPrintJob;
}
jayfour000 is offline   Reply With Quote
Old 04-20-2004, 08:34 AM   #4
jcolletti
Registered User
 
jcolletti's Avatar
 
Join Date: Aug 2002
Location: Upstate New York
Posts: 52
Default Close but no cigar?

First of all...thank you greatly for addressing my dilema.
I tried your code as follows...the only thing I modified was the text field instance name and the printable height and width dimensions (pasted below)

When the job gets sent to the printer it prints out like >200 pages!
Even more intresting...the very last page is the only one with the remaining content spilled over..all of the other pages are just duplicates of the first printed page?

//The code I adapted from the post (above)

printText_mc.onRelease = function() {
//create PrintJob object
myPrintJob = new PrintJob();
//display print dialog box
myPrintJob.start();
var maxS:Number; //total number of lines in textArea
var botS:Number; //total number of lines visible in scroll box
//loop through untill i have added a page for each scroll pane
for (var i = 1; botS*i<=maxS; i++) {
// add specified area to print job
myPrintJob.addPage("printer_txt", {xMin:0, xMax:600, yMin:0, yMax:800}, {printAsBitmap:false});
maxS = printer_txt.label.maxscroll;
botS = printer_txt.label.bottomScroll;
//manually scroll the box
printer_txt.vPosition = botS;
}
// send pages from the spooler to the printer
myPrintJob.send();
// clean up
delete myPrintJob;
};
jcolletti is offline   Reply With Quote
Old 04-09-2008, 05:20 PM   #5
swayzeman
Registered User
 
Join Date: Apr 2008
Posts: 7
Default

I was struggling to find a solution on how I could print the entire contents of a scrolling Text field for the past 2 days using AS2. AS with alot of people, I could only print the visible area of the pane. You would think there would be alot of documentation on this, this beeing such a common task but there isnt. Doing the same in AS3 is also a bit of a task...

Anyway, I thought I would share my solution. What I'm doing is taking the text (html text in this case) from my scrolling text field and putting it in another one that I created on the fly measured to fit a standard page. Since I know it fits one page, I add a page to the print job and then simply scroll down to the next page until all the pages have been added. Hopefully it saves someone else from spending days figuring out how to do something so trivial.

btn_print.onRelease = function()
{

//550 width and 750 height is good for a fullpage
//Change it to fit your needs
createTextField("PrintableText", 0, 0, 0, 550, 750);
PrintableText._x = -1000; //put it off the screen
PrintableText.html = true;
PrintableText.multiline = true;
PrintableText.wordWrap = true;
PrintableText.htmlText = "YOUR TEXT FROM YOUR SCROLL PANE HERE"
var maxX = PrintableText._width;
var maxY = PrintableText._height;


var currentScroll:Number = PrintableText.scroll;
//scroll to the top of the page
PrintableText.scroll = 1;
// get the maximum amount of lines
var maxScroll:Number = PrintableText.maxscroll;
// get the lines that can show per page
var bottomLine:Number = PrintableText.bottomScroll;


my_pj = new PrintJob();
var started = my_pj.start();

if(started)
{
var counter:Number = 0;
for(count = 1; count < maxScroll; count ++)
{
my_pj.addPage(PrintableText , {xMin:0, xMax:maxX, yMin:0, yMax:maxY}, null, 2);
count += bottomLine;
//just scroll down the page so the next text you want to print is visible
PrintableText.scroll = count;

}
}
my_pj.send();
delete my_pj;
}

Cheers,

Swayzeman

Last edited by swayzeman; 04-09-2008 at 05:23 PM. Reason: typo
swayzeman is offline   Reply With Quote
Old 04-10-2008, 01:42 PM   #6
nikoka
Registered User
 
Join Date: Apr 2008
Posts: 2
Default

Hi swayzeman!

Been struggling with the same thing for some time now, your solution is absolutely the best I've seen so far, but I don't know if I'm missing something or what, but I can't seem to get the script to print more than two pages. Do you know what might cause this sort of behavior?

Kind regards,
Niko
nikoka is offline   Reply With Quote
Old 04-14-2008, 02:15 PM   #7
swayzeman
Registered User
 
Join Date: Apr 2008
Posts: 7
Default

Hi Niko,

Im not sure. works for me, Ive made a test and printed about 10 pages with no problems. It should work pretty much on any scrolling text field.


if you can post your code I'll take a look.

Swayzeman
swayzeman is offline   Reply With Quote
Old 04-28-2008, 08:43 AM   #8
nikoka
Registered User
 
Join Date: Apr 2008
Posts: 2
Default

Sorry, hadn't noticed your reply before now. The code is now pretty much the same as you're using, I'm pulling the text from an XML-file into a TextArea with the instance name "myText".

I'm a bit perplexed because I can't find the reason why it stops after two pages.

Kind regards,
Niko


btn.onRelease = function()
{

createTextField("PrintableText", 0, 0, 0, 550, 750);
PrintableText._x = -1000; //put it off the screen
PrintableText.html = true;
PrintableText.multiline = true;
PrintableText.wordWrap = true;
PrintableText.htmlText = _root.myText.text;
var maxX = PrintableText._width;
var maxY = PrintableText._height;

var currentScroll:Number = PrintableText.scroll;
//scroll to the top of the page
PrintableText.scroll = 1;
// get the maximum amount of lines
var maxScroll:Number = PrintableText.maxscroll;
// get the lines that can show per page
var bottomLine:Number = PrintableText.bottomScroll;

my_pj = new PrintJob();
var started = my_pj.start();

if(started)
{
var counter:Number = 0;
for(count = 1; count < maxScroll; count ++)
{
my_pj.addPage(PrintableText , {xMin:0, xMax:maxX, yMin:0, yMax:maxY}, null, 2);

count += bottomLine;
//just scroll down the page so the next text you want to print is visible
PrintableText.scroll = count;

}
}
my_pj.send();
delete my_pj;
}

/******************************/
//init TextArea component
myText.html = true;
myText.wordWrap = true;
myText.multiline = true;

/******************************/
//load in XML
textCcontent = new XML();
textCcontent.ignoreWhite = true;
textCcontent.load("data.xml");
textCcontent.onLoad = function(success)
{
if(success)
{
myText.text = textCcontent;
}
}
nikoka is offline   Reply With Quote
Old 06-17-2009, 06:45 PM   #9
macman66
Registered User
 
Join Date: Jun 2009
Location: Charlotte, NC
Posts: 6
Red face I know it's me.... :)

Hi, guys...and THANK YOU. I'm currently using the following code, needing to print all of the contents of my scrolling input text field. Any and all help for this noob will be appreciated!

printButton.onRelease = function()
{

//550 width and 750 height is good for a fullpage
//Change it to fit your needs
createTextField("PrintableText", 0, 0, 0, 550, 750);
PrintableText._x = -1000; //put it off the screen
PrintableText.html = true;
PrintableText.multiline = true;
PrintableText.wordWrap = true;
//Am I improperly pulling the contents of my movie clip, which contains the text field (below)?
PrintableText.htmlText = (notesfield,"bmovie");
var maxX = PrintableText._width;
var maxY = PrintableText._height;


var currentScroll:Number = PrintableText.scroll;
//scroll to the top of the page
PrintableText.scroll = 1;
// get the maximum amount of lines
var maxScroll:Number = PrintableText.maxscroll;
// get the lines that can show per page
var bottomLine:Number = PrintableText.bottomScroll;


my_pj = new PrintJob();
var started = my_pj.start();

if(started)
{
var counter:Number = 0;
for(count = 1; count < maxScroll; count ++)
{
my_pj.addPage(PrintableText , {xMin:0, xMax:maxX, yMin:0, yMax:maxY}, null, 2);
count += bottomLine;
//just scroll down the page so the next text you want to print is visible
PrintableText.scroll = count;

}
}
my_pj.send();
delete my_pj;
}
macman66 is offline   Reply With Quote
Old 06-18-2009, 07:05 AM   #10
swayzeman
Registered User
 
Join Date: Apr 2008
Posts: 7
Default re: I know it's me.... :)

The problem seems to be that you arent actually accessing the .text from your notes field. It should probably be something like "_root.notesField.text".

I would play around with that. Try placing a trace to see what comes up as your text. It shouldnt say instancewhatever.instancewhatever... It should give you the ctual text

Hope this helps
swayzeman
swayzeman is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.