2

The following code throws java.lang.ClassCastException

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new MediaSize(60,80,Size2DSyntax.MM));

I suspect I did line 2 incorrectly, but I cannot find detailed documentation for Java printing services. What is the proper way to define custom media size?

4

1 回答 1

3

MediaSize没有实现PrintRequestAttribute,因此出现错误。

相反,我认为,你需要使用类似的东西

aset.add(new MediaPrintableArea(5, 5, 50, 80, MediaPrintableArea.MM));

反而...

您可以查看MediaPrintableArea了解我的详细信息。

于 2012-09-20T19:24:11.053 回答