質問

I am looking for a solution where text and images are dynamically generated based on user UI content, and then printed on a simple "one click" basis.

My intention thus far (from having done a little research) is to create a JTextComponent who's content will be generated based on the user's input (indirectly) and simply print the JTextComponent. This JTextComponent will never be displayed in the UI anywhere, only printed.

So far I set up a temporary test using;

    JTextArea report = new JTextArea("Test Text");
        try {
            report.print();
        } catch (PrinterException ex) {
            ex.printStackTrace();
        }

This brings up the print menu correctly (I will later specify against the menu coming up at all) but prints a blank page.

Q1: Is this a viable way of going about this?

Q2: Can anyone tell me why the pages are printing blank?

役に立ちましたか?

解決

You should set the report's size. In opposite case it's just 0,0 sized.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top