1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
29 import java.io.File;
30 import java.io.FileInputStream;
31 import java.io.FileOutputStream;
32 import java.io.IOException;
33 import java.nio.charset.StandardCharsets;
34 import javax.print.DocFlavor;
35 import javax.print.DocPrintJob;
36 import javax.print.SimpleDoc;
37 import javax.print.StreamPrintService;
38 import javax.print.StreamPrintServiceFactory;
39 import javax.print.attribute.HashDocAttributeSet;
40 import javax.print.attribute.HashPrintRequestAttributeSet;
41 import javax.print.event.PrintJobAdapter;
42 import javax.print.event.PrintJobEvent;
43
44 /*
45 * @test
46 * @bug 8067364
47 * @summary Printing to Postscript doesn't support dieresis
48 * @build PrintSEUmlauts
49 * @run main/othervm PrintSEUmlauts
50 */
51 public class PrintSEUmlauts implements Printable {
52
53 public static void main(String[] args) throws Exception {
54
55 GraphicsEnvironment.getLocalGraphicsEnvironment();
56
57 DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
58 String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
59
60 StreamPrintServiceFactory[] factories =
61 StreamPrintServiceFactory.
62 lookupStreamPrintServiceFactories(flavor, mime);
63 if (factories.length == 0) {
64 System.out.println("No print service found.");
65 return;
66 }
67
68 FileOutputStream output = new FileOutputStream("out.ps");
69 StreamPrintService service = factories[0].getPrintService(output);
|
1 /*
2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
29 import java.io.File;
30 import java.io.FileInputStream;
31 import java.io.FileOutputStream;
32 import java.io.IOException;
33 import java.nio.charset.StandardCharsets;
34 import javax.print.DocFlavor;
35 import javax.print.DocPrintJob;
36 import javax.print.SimpleDoc;
37 import javax.print.StreamPrintService;
38 import javax.print.StreamPrintServiceFactory;
39 import javax.print.attribute.HashDocAttributeSet;
40 import javax.print.attribute.HashPrintRequestAttributeSet;
41 import javax.print.event.PrintJobAdapter;
42 import javax.print.event.PrintJobEvent;
43
44 /*
45 * @test
46 * @bug 8067364
47 * @summary Printing to Postscript doesn't support dieresis
48 * @build PrintSEUmlauts
49 * @run main/othervm -Dfile.encoding=ISO-8859-1 PrintSEUmlauts
50 */
51 public class PrintSEUmlauts implements Printable {
52
53 public static void main(String[] args) throws Exception {
54
55 GraphicsEnvironment.getLocalGraphicsEnvironment();
56
57 DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
58 String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
59
60 StreamPrintServiceFactory[] factories =
61 StreamPrintServiceFactory.
62 lookupStreamPrintServiceFactories(flavor, mime);
63 if (factories.length == 0) {
64 System.out.println("No print service found.");
65 return;
66 }
67
68 FileOutputStream output = new FileOutputStream("out.ps");
69 StreamPrintService service = factories[0].getPrintService(output);
|