How to realize the function of Flex4 printing
How to achieve Flex4 printing function, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The steps of Flex4 printing function and Silverlight4 printing function are very similar, but the implementation is different. Flex4 printing function is not event-driven. The basic steps are described below.
Flex4 printing function
The steps of Flex4 printing function and Silverlight4 printing function are very similar, but the implementation is different. Flex4 printing function is not event-driven. The basic steps are as follows:
Step 1: create a FlexPrintJob object that can be thought of as the PrintDocument of Silverlight
Step 2: use a Boolean variable to control the format of the picture to be printed, such as a vector map or a bitmap
Step 3: call the Start () method in FlexPrintJob, and a prompt window will pop up, asking if you want to start printing, select OK, and you will start printing.
Step 4: create a print object and add the print object to the reality list
Step 5: add objects to the print page using addObject () in FlexPrintJob
Step 6: call the send () method in FlexPrintJob to print the added print page
Step 7: after printing, delete the printed view object
The button event code is provided below. After clicking the button, "HelloWorld" will be printed.
Protectedfunctionbutton1_clickHandler (event:MouseEvent): void {varjob:FlexPrintJob=newFlexPrintJob (); job.printAsBitmap=false; if (job.start ()) {vargroup:HGroup=newHGroup (); group.height=job.pageHeight; group.width=job.pageWidth; vartext:SimpleText=newSimpleText (); text.text= "Hello"; text.setStyle ("fontFamily", "Arial"); text.setStyle ("fontSize", 12); group.addElement (text); text=newSimpleText (); text.setStyle ("fontFamily", "Arial") Text.setStyle ("fontSize", 12); text.text= "World"; group.addElement (text); addElement (group); job.addObject (group,FlexPrintJobScaleType.NONE); job.send (); removeElement (group);}
Comparing the above two groups of print codes, we can see that Flex printing requires some more parameters, mainly because:
1. In Flex printing, you need to set the print format, bitmap mode or vector map mode.
2.Flex does not support automatically setting the width and height of printed objects in the printed page.
We can see that the printing function of Flex4 is more sound than that of Silverlight. High-quality vector graphics and automatic paging are the two main highlights in Flex printing, while the current automatic paging in Silverlight4 is to cut the printed view object into two parts to achieve printing. The full programming mode of printing function in Silverlight4 is also the highlight of Silverlight. From the perspective of Microsoft's positioning of Silverlight, I believe that in the near future, the printing function of Silverlight will be more powerful and perfect.
After reading the above, have you mastered how to implement the Flex4 printing function? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!