I am doing a project in javafx in which we create forms ( forms like admission form etc)
Form contains many labels,textfields (filled with data from database) and some images.
I want to print these labels, data from textfields and the images in the same layout in which they were created ( I mean, after printing textfield1 should not be in front of label2 etc).
Is is possible? or is it possible to convert this form to pdf file so that it could be printed later?
Thanks.
It is possible to take a snapshot of the Scene:
Scene scene;
WritableImage image = scene.snapshot(null);
And then you can save this image in an image format:
http://java-buddy.blogspot.com/2012/12/save-writableimage-to-file.html
Related
This relates to JavaFX: I have a 'Products' window which contains a TableView filled with a products list, a few buttons (Edit, Delete, Add, Search) and an ImageView with the picture of the currently selected product (this pic changes correctly on click).
Clicking on the 'Edit' button opens a new window where I can change the image file for the product and correctly saves the new pic to the file system (one note here: the new image overwrites the old one, meaning the image path/filename remains the same).
When I close this 'Edit' window, I clean the picture in the ImageView control by doing:
imageView.setImage(null);
and then I set the "new" image:
imageView.setImage(new Image(path));
Setting the image to null efectively removes the old image, however, the imageView container keeps showing the "old picture" after setting the new one. Is there any kind of chache that needs to be cleaned? How can I "tell" the ImageView container that the image has changed, even though the filename is the same?
Thanks for the help, and sorry for my bad english.
After two weeks I finally found the solution:
Instead of saving the new image using the same file name, I now use a new filename, then update the database table and delete the old file from disk.
Images are not longer loaded using imageView.setImage(new Image(path)); Instead, now I load images using:
File img = new File(pathObtainedFromDatabase);
InputStream isImage = (InputStream) new FileInputStream(img);
imageView.setImage(new Image(isImage));
Thanks to all that tried to help.
Using Qt, I am working on a tool that displays items in a QGraphicsScene. Items are both polygons and QGraphicsTextItems. The latter can contain hyperlinks.
Problem: I am trying to export the diagrams and I would like to keep the hyperlinks active.
Using QImage renderers produce nice PNG but (obviously) no hyperlinks.
QSvgRenderer produce SVG that also do not embed the hyperlinks.
QPrinter allows to generate PDF that do the job (more or less) - hyperlinks are clickable, and that is what I need in principle. Except that I want to publish the diagram on the web, so PDF is not really an option for me.
I could not find any way render the QGraphicsScene in an HTML form. Did I miss something? Is there a way to do that?
Thanks
EDIT
A code example:
from PySide import QtGui, QtCore
app = QtGui.QApplication([])
scene = QtGui.QGraphicsScene()
view = QtGui.QGraphicsView(scene)
item = QtGui.QGraphicsTextItem()
item.setOpenExternalLinks(True)
item.setHtml('Hello')
item.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
scene.addItem(item)
view.show()
app.exec_()
This example displays a scene with a clickable hyperlink (that opens the link with the default system application). In my application the scene also contains some graphical item but I think this is sufficient to get the idea: I would like to have this scene rendered (or printed or exported) in HTML so that the links would remain clickable.
The following code does the export to PDF:
pdf_printer = QPrinter()
pdf_printer.setOutputFormat(QPrinter.PdfFormat)
pdf_printer.setPaperSize(rect.size().toSize(), QPrinter.Point)
pdf_printer.setFullPage(True)
pdf_printer.setOutputFileName(filename)
pdf_painter = QPainter()
pdf_painter.begin(pdf_printer)
scene.render(pdf_painter, source=rect)
pdf_painter.end()
And the resulting PDF does contains the active hyperlinks - this is what makes me thinks that all the mechanics is there. I just cannot find a way to export in HTML instead of PDF.
With interface builder for xcode 3 i could rename an object by clicking on its name in the outline view. Is there a way to rename objects in interface builder for xcode 4? Because an outline like this:
View
View
View
View
View
View
View
could be a little more informative.
There are two ways to rename the objects. First, select an object and open the identity inspector. In the Identity section there is a Label text field. Enter the name in the text field.
Second, you can change the object list, which runs along the left side of the editor, from the icon view to the hierarchical view. The hierarchical view shows the document outline, which looks similar to the following screenshot:
Select an object from the object list and press the Return key to rename the object. How you change to the hierarchical view depends on the Xcode 4 version you're using. Newer versions have a button in the lower left corner of the canvas that toggles the icon and hierarchical views. Older versions have a small button at the bottom of the object list.
Is there a way to create a BarChart (in the background) without adding it to the current view? I basically have a chart that I need to convert to an image and add it to a PDF report (using AlivePDF).
No, you must add the the chart to the display list.
A DisplayObject must be added to the display list in order to be able to render out as a Bitmap (i.e. to print it or to send it to a PDF).
Internally AlivePDF uses the BitmapData.draw(...); method which requires the object to be on the display list and have visible=true in order to be rendered out.
If you don't want the chart to appear on the stage whilst you are generating your PDF (or printing) then you can add the chart to a parent container and hide the parent instead.
Here is an example of how you can do that:
var box:VBox = new VBox();
// Hide the parent, not the chart.
// If you set chart.visible = false then it won't show up in the PDF.
box.visible = false;
box.addChild(chart);
addChild(box);
// You might need to force validation here so the chart has the correct size.
box.validateNow();
// Add chart to PDF.
pdf.addImage(chart);
// TODO: Clean up your display items here.
box.removeChild(chart);
removeChild(box);
box = null;
I have created one button component using one Bitmap and one Label in it.
Thing is that when user Clicks on on the button I want to changes button's Icon/Image and Label Text.
I want to do this using FlashCS5 and ActionScript-3.
I have tried following but it gives me runtime Error
[Bindable]
[Embed(source="/Images/test.png")]
var testIcon:Class;
testButton.setStyle("icon", testIcon);
Is there any other way of doing this.
Thanks.
You need to instantiate testIcon first. Try doing this:
[Embed(source="/Images/test.png")]
var testIcon:Class;
var btnGraphics:Bitmap = new testIcon();
testButton.setStyle("icon", btnGraphics);
Looking at what you want to archive i think you should follow following steps
1. Create one movie clip using new symbol
2. Create Two new Button Symbol using 2 different images and label
3. insert these button into the key frames for the created movie clip
you can use this movieClip to create new buttons that can have 2 states
just use gotoAndStop to display the proper button.
This is an answer for a followup that ppp asked:
There is a property labelPlacement="right|left|bottom|top" property. Default is right if you set it to bottom, the icon will show above the text.
You can create a button skin in flash and import them into flex. My experience with flex 3 skins imported from Flash is that it takes a bit of work and back and forth to get it working perfectly. Flash Catalyst for Flex 4 has greatly improved that workflow.