93
\$\begingroup\$

Yes, really. Print it with a hardware printer 🖨 to create a hard copy.

Send the necessary commands/data to your printer such that the following text is printed on a piece of paper:

Hello, World!

You may use any local- or network-connected printer that is available to you.

If your printer allows, you should use 8pt or greater text in black ink on white paper.

The text should appear on its own line. It may be left or right positioned as you wish.

Digital photographic/video/GIF evidence of submissions will be helpful.

If your hardware cannot do paper, but allows other exotic hardcopy production such as 3D printing, CNC machining, or printing at the atomic level, then I will happy to accept such interesting submissions.


To clarify, the question asks "Send the necessary commands/data to your printer". The implication of this is that no further user input should be required. Opening a print dialog is not sufficient. Existing answers that do this as of 10:48am PST 31st Dec 2016 will be grandfathered (but not upvoted by me).

asked Dec 30, 2016 at 21:37
\$\endgroup\$
11
  • 66
    \$\begingroup\$ Please supply address to which we can send submissions for verification. \$\endgroup\$ Commented Dec 30, 2016 at 21:38
  • 1
    \$\begingroup\$ @steenbergh Yep - good point - Digital photographic/video/GIF evidence of submissions should be good enough. \$\endgroup\$ Commented Dec 30, 2016 at 21:41
  • 3
    \$\begingroup\$ It's worth noting that many older printers use custom command sets. Most of these print ASCII characters literally, so if you have access to one of the printers in question (or can just claim that you do), sending Hello, World! to the printer port should be enough. \$\endgroup\$ Commented Dec 30, 2016 at 22:30
  • 3
    \$\begingroup\$ I could swear that I tried print("Hello, World!") in the Firefox console once and it opened the print dialogue (useless because I wasn't connected to a printer in any way), but now it just returns the string... \$\endgroup\$ Commented Dec 31, 2016 at 1:54
  • 5
    \$\begingroup\$ @ETHproductions in chrome doing <script>print("Hello, World!")</script> does open the print dialog, but without the actual text on it. \$\endgroup\$ Commented Dec 31, 2016 at 10:23

29 Answers 29

43
\$\begingroup\$

Bash, (削除) 21 (削除ここまで) 19 bytes

lp<<<Hello,\ World!

actual printout

And there it is.

2 bytes saved thanks to Dennis!

answered Dec 30, 2016 at 21:41
\$\endgroup\$
3
  • 1
    \$\begingroup\$ +1 Valid as a script. Works fine on my Mac. If you want to run it directly at the command-line you'll need to change the double-quotes to single-quotes. \$\endgroup\$ Commented Dec 30, 2016 at 21:45
  • \$\begingroup\$ why not have banner to make ot look pretty \$\endgroup\$ Commented Jan 1, 2017 at 19:43
  • \$\begingroup\$ @juggernaut1996 where? Not if I have to print something out again \$\endgroup\$ Commented Jan 1, 2017 at 19:46
39
\$\begingroup\$
answered Dec 31, 2016 at 0:12
\$\endgroup\$
4
  • 10
    \$\begingroup\$ Not sure the point of the TIO link. +1 anyway. \$\endgroup\$ Commented Dec 31, 2016 at 0:20
  • 2
    \$\begingroup\$ @DigitalTrauma I thought it was funny; and it generates the post for me. You can also look at the debug output just to see that it's trying (and failing) to spool the job. :-p \$\endgroup\$ Commented Dec 31, 2016 at 0:21
  • 25
    \$\begingroup\$ @DigitalTrauma If you put your address in the input field, TIO will mail you the result. \$\endgroup\$ Commented Dec 31, 2016 at 0:23
  • \$\begingroup\$ @Dennis if I had money to burn I'd submit an answer that uses an API-to-print service. Alas... \$\endgroup\$ Commented Dec 31, 2016 at 0:25
20
\$\begingroup\$

QBIC, 11 bytes

'LPRINT `_h

Almost forgot I built a 'Hello, World!' command into QBIC...

' Starts a code literal. This used to be "$", finally changed it.
 LPRINT ` Feeds everything from ` to the next ` directly to QBasic. 
 In this case, "LPRINT" and a space
_h Yields "Hello, World!"

Tested and found working identical to my QBasic answer: enter image description here

answered Dec 30, 2016 at 22:42
\$\endgroup\$
5
  • 1
    \$\begingroup\$ um.. so what's that link? Is it a language invented by you? \$\endgroup\$ Commented Dec 30, 2016 at 22:47
  • 1
    \$\begingroup\$ @eis Yes, I made QBIC. The link is a Google Drive folder with all the code in it - I suck at GitHub... It's an interpreter atop of QBasic (QBIC stands for Quick Basic's Interpreter for Codegolf) and it runs in DosBox. Check out the Showcase-thread for some examples (or just open my profile's answers-page, 75% is in QBIC). WIP, so syntax and tokens occasionally get shifted. \$\endgroup\$ Commented Dec 30, 2016 at 22:50
  • \$\begingroup\$ The OP used a capital "W" to avoid builtin "hello world" (see also).: building your own builtin command for the job is not code golfing, or you could make it "0 bytes" with a builtin default behavior for that. \$\endgroup\$ Commented Jan 2, 2017 at 4:45
  • 3
    \$\begingroup\$ @Cœur: that hardly works nowadays, most newer golfing languages use the capital W precisely because it's standard on PPCG, and it's highly likely that the command was added with no knowledge of this particular challenge (just a guess that more "Hello, World!" challenges would be submitted in the future) \$\endgroup\$ Commented Jan 2, 2017 at 11:01
  • \$\begingroup\$ @Cœur Welcome to PPCG! You may be surprised to learn that you're not the first person to whom that particular concern has occurred. Here's a good place to start reading: meta.codegolf.stackexchange.com/q/4867/11261 And further, people who enjoy code golfing spend a lot of time thinking about loopholes: meta.codegolf.stackexchange.com/q/1061/11261 \$\endgroup\$ Commented Jan 3, 2017 at 4:32
17
\$\begingroup\$

Batch, 22 bytes

echo Hello, World!>prn

This redirects the output of the echo command to the device file PRN, meaning that it's sent directly to the default printer (usually LPT1).

I neither have a DOS machine nor a printer, so I'm afraid I can't test this right now, but I'm fairly certain I've done this back in the day. It doesn't work on Windows XP or later.

answered Dec 30, 2016 at 21:51
\$\endgroup\$
2
  • \$\begingroup\$ This reminds of when I tried to create a file called con and was unable to. Ah, the joy of DOS device files... \$\endgroup\$ Commented Jan 2, 2017 at 14:02
  • \$\begingroup\$ NT (and presumable XP etc) can be configured to print this way using the "net" command. iirc "net use lpt1: something" \$\endgroup\$ Commented Feb 4, 2017 at 10:28
16
\$\begingroup\$

Python 2.7, 43 bytes

import os;os.system("lp<<<'Hello, World!'")

Not very interesting, though. Here's a more interesting one:

import zlib,base64,os;os.system("s=$'%s';lp<<<\"$s\""%zlib.decompress(base64.decodestring("eNqVkk1qxDAMha/yupNgwNfoDboReDPdhQRmrcNXP3bixA3tGEMesj/r5wXoq+YysUemI0BWlYgV\npTyAEDKEQSDucxLxJaj6gUVKE8BFsH2TIOM5iMyrcTIL3YnMqCH4X0TLONTwF3H04Z0XuRPeR3Wi\nxDOi1EZY7gUTWFa8s+z5kTgcnK3sBtbZQRtCt5LPDlrliKouDh5DYz07KB6COuETUL/YRthGxHqZ\nbjyWBAU8EFk6z350Yt97Dol65hxUow9i3zr8YGxFS61nB4szPqvDnS7CU/nFwYLIYczn97JsD3xt\nr+X5wT/ARNN3\n")))

Seems a bit too long? Perhaps it's a bit overcomplicated.... :P

A lot of hello world

Mod Note edited the competitive submission to the top for clarity.

hyperneutrino
42.8k5 gold badges72 silver badges227 bronze badges
answered Dec 31, 2016 at 6:59
\$\endgroup\$
0
15
\$\begingroup\$

HTML + Javascript, (削除) 37 (削除ここまで) 34 bytes

<body onload=print()>Hello, World!

Tested in Safari:

enter image description here

Thanks to @jimmy23013 for some savings.

answered Dec 31, 2016 at 4:09
\$\endgroup\$
9
  • 13
    \$\begingroup\$ This appears just to open the print dialog box and not actually send the job to the printer without further manual intervention \$\endgroup\$ Commented Dec 31, 2016 at 5:00
  • 4
    \$\begingroup\$ @DigitalTrauma JS cannot do that \$\endgroup\$ Commented Dec 31, 2016 at 11:07
  • 1
    \$\begingroup\$ Also, you can shave 9 bytes off by omitting </script>. \$\endgroup\$ Commented Dec 31, 2016 at 14:35
  • 2
    \$\begingroup\$ Are you sure, @EriktheOutgolfer? Firefox and Chrome evaluates the script code only when the closing tag is met. \$\endgroup\$ Commented Dec 31, 2016 at 16:41
  • 3
    \$\begingroup\$ -3 bytes: <body onload=print()>Hello, World! \$\endgroup\$ Commented Jan 1, 2017 at 6:38
13
\$\begingroup\$

hello + lp + tr, (削除) 9 (削除ここまで) 15 bytes

hello|tr w W|lp

I originally had

hello|lp

But it had the wrong capitalisation on the w

hello is GNU hello from the Debian package hello

answered Dec 31, 2016 at 4:59
\$\endgroup\$
5
  • 7
    \$\begingroup\$ hello prints a lowercase w, as is the custom on most programming sites. (I'm not quite sure how the uppercase W became standard on PPCG.) \$\endgroup\$ Commented Dec 31, 2016 at 6:25
  • 7
    \$\begingroup\$ @ais523 I think uppercase W is standard here precisely to avoid built ins like this. \$\endgroup\$ Commented Dec 31, 2016 at 7:20
  • 2
    \$\begingroup\$ If the capitalization is wrong, I'm afraid this is invalid. \$\endgroup\$ Commented Dec 31, 2016 at 16:25
  • \$\begingroup\$ Thanks for your comments, I will delete this answer tomorrow. \$\endgroup\$ Commented Jan 1, 2017 at 4:40
  • 6
    \$\begingroup\$ How about hello|tr w W|lp? \$\endgroup\$ Commented Jan 1, 2017 at 13:32
11
\$\begingroup\$

ZX Spectrum BASIC, 16 bytes

LPRINT "Hello, World!"

LPRINT is a 1-byte keyword in ZX Spectrum BASIC, having codepoint 224.

answered Dec 30, 2016 at 23:55
\$\endgroup\$
3
  • 1
    \$\begingroup\$ can you show a photo of the hardcopy. \$\endgroup\$ Commented Dec 31, 2016 at 4:56
  • 6
    \$\begingroup\$ @Jasen In theory I still have the kit around, but it would be a bit of a palaver to dig it out and hook it up to an old enough TV. Sorry about that. \$\endgroup\$ Commented Dec 31, 2016 at 9:50
  • \$\begingroup\$ you could probably type that command "blind". \$\endgroup\$ Commented Dec 31, 2016 at 9:56
10
\$\begingroup\$

MATLAB, (削除) 40 (削除ここまで) (削除) 37 (削除ここまで) 36 bytes

Printing text is not something you'd normally do in Matlab, but it can be done.

title 'Hello, World!'
axis off;print

I saved 3 bytes thanks to Tom Carpenter (use title instead of text(0,0,. I saved an additional 2 bytes by substiting title('Hello, World!') with title 'Hello, World!' followed by a newline instead of a semicolon.

title adds a title to a figure. If a figure is not yet open, it will be created.

axis off is used to get rid of the frame and axes, so that the text appears alone.

print prints the current figure to the default printer if no input arguments are given.

I printed this (successfully according to the dialog box) on my default printer at the office. I can retrieve it there and prove it but you'll have to wait two weeks. After changing the default to a pdf-printer, this is the output:

enter image description here

^^ Not the correct image anymore.

answered Dec 30, 2016 at 23:44
\$\endgroup\$
0
8
\$\begingroup\$

QBasic, 21 bytes

LPRINT"Hello, World!"

LPRINT sends text directly to the printer. Unfortunately untested, DosBox doesn't natively support NET USE, so I can't reroute LPT1: to NovaPDF.

The problems I have...

UPDATE: Tested it in QB64. Resulting PDF opened in Microsoft Edge. Looks like this: enter image description here

answered Dec 30, 2016 at 21:52
\$\endgroup\$
7
\$\begingroup\$

Java, 330 bytes

Golfed:

import java.awt.print.*;void f()throws Throwable{PrinterJob job=PrinterJob.getPrinterJob();job.setPrintable(new Printable(){public int print(java.awt.Graphics g,PageFormat f,int i){if(i==0){((java.awt.Graphics2D)g).translate(f.getImageableX(),f.getImageableY());g.drawString("Hello, World!",0,90);}return i>0?1:0;}});job.print();}

Ungolfed (import plus function only):

import java.awt.print.*;
void f() throws Throwable {
 PrinterJob job = PrinterJob.getPrinterJob();
 job.setPrintable(new Printable() {
 public int print(java.awt.Graphics g, PageFormat f, int i) {
 if (i == 0) {
 ((java.awt.Graphics2D) g).translate(f.getImageableX(), f.getImageableY());
 g.drawString("Hello, World!", 0, 90);
 }
 return i > NO_SUCH_PAGE ? 1 : PAGE_EXISTS;
 }
 });
 job.print();
}

Java is not a great golfing language, and certain does an exceptionally poor job golfing anything hardware-related, printing included.

While testing this program, I set my PDF printer as the default. It worked, but also sent a print job to my laser printer containing 87,792 pages of "Hello, World!" I pulled the paper tray and canceled the job, then retested. It did not happen again. Thanks, Windows 10.

Riker
7,9284 gold badges40 silver badges73 bronze badges
answered Jan 3, 2017 at 5:29
\$\endgroup\$
1
  • 3
    \$\begingroup\$ -7 bytes by changing 3x job to j, and i==0 to i<1. \$\endgroup\$ Commented May 23, 2017 at 14:51
7
\$\begingroup\$

8086 machine code, 28 bytes

00000000 be 0f 01 b9 0d 00 31 d2 ac 98 cd 17 e2 fa c3 48 |......1........H|
00000010 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 |ello, World!|
0000001c

Uses the standard int 0x17 BIOS call. I don't have my dot-matrix printer set up right now so this code is untested.

How it works:

 | org 0x100
 | use16
be 0f 01 | mov si, msg ; source pointer = msg
b9 0d 00 | mov cx, 13 ; counter = length of msg
31 d2 | xor dx, dx ; clear dx
ac | @@: lodsb ; al = *si++
98 | cbw ; sign-extend al->ax (simply clears ah)
cd 17 | int 0x17 ; send char in al to printer dx
e2 fa | loop @b ; loop while (cx-- > 0)
c3 | ret
48 65 6c | msg db "Hello, World!"
6c 6f 2c | 
20 57 6f | 
72 6c 64 | 
21 | 
answered Apr 21, 2017 at 22:00
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Sure, just added it. \$\endgroup\$ Commented Apr 22, 2017 at 4:04
  • \$\begingroup\$ Now we're talking! \$\endgroup\$ Commented May 3, 2017 at 19:24
  • \$\begingroup\$ Absurdly late reply, but a byte can be saved by using cwd after cbw instead of xor dx, dx. \$\endgroup\$ Commented Feb 16, 2021 at 6:52
6
\$\begingroup\$

Stuck + Batch, 5 bytes

Inspired by this answer an empty stuck program prints "Hello, World!".

  1. Have a printer connected to your computers LPT1 port
  2. Create an empty stuck file to be interpreted (filename a)
  3. Run the stuck interpretter on the empty file and pipe the result to LPT1

Code

stuck a>LPT1
caird coinheringaahing
50.9k11 gold badges133 silver badges364 bronze badges
answered Jan 2, 2017 at 9:46
\$\endgroup\$
8
  • 4
    \$\begingroup\$ If you're using multiple languages, you also need to count the glue that connects them together as part of your byte count. I'd count this as 15 for the Batch program, plus 0 due to the need for a 0-byte external file. \$\endgroup\$ Commented Jan 2, 2017 at 10:59
  • 2
    \$\begingroup\$ Can you show distinctly the Windows batch script, and explicitly the command used to call Stuck and pass the result to the printer? By explicitly I mean something like stuck empty > LPT1. BTW if this uses a REPL I believe the consensus is that should be clearly stated (I believe it's to minimise confusion exactly like this). \$\endgroup\$ Commented Jan 2, 2017 at 14:39
  • 1
    \$\begingroup\$ You can save a byte here by redirecting to PRN instead of LPT1. \$\endgroup\$ Commented Apr 22, 2017 at 6:10
  • 1
    \$\begingroup\$ IMO you need to add 1 byte for the 1 byte filename. \$\endgroup\$ Commented May 30, 2017 at 21:40
  • 1
    \$\begingroup\$ @Makonede Don't edit people's code in order to fix it, leave a comment pointing out the problem and potentially suggesting a fix \$\endgroup\$ Commented May 28, 2021 at 16:47
4
\$\begingroup\$

GFA-Basic, 22 bytes

Only tested on an Atari ST emulator with the parallel port redirected to a file. It should work on the Windows version of GFA-Basic (which is free), but this is untested.

LPRINT "Hello, World!"

Note: This turns out to be identical to the QBasic syntax.

answered Dec 30, 2016 at 23:23
\$\endgroup\$
2
\$\begingroup\$

Mathematica, 29 bytes

NotebookPrint@"Hello, World!"

enter image description here

answered Dec 31, 2016 at 10:21
\$\endgroup\$
2
\$\begingroup\$

JavaScript, (削除) 37 (削除ここまで) 36 bytes

print(document.write`Hello, World!`)

Saved 15 bytes thanks to @manatwork and @xem!

answered Dec 31, 2016 at 7:10
\$\endgroup\$
5
  • 3
    \$\begingroup\$ No need to explicitly specify window: document.write('Hello, World!');print(). Or even shorter: print(document.write('Hello, World!')). \$\endgroup\$ Commented Dec 31, 2016 at 11:08
  • 3
    \$\begingroup\$ with ES6 you can even do: document.write`Hello, world!` (more info here: xem.github.io/articles/#webspeech) \$\endgroup\$ Commented Dec 31, 2016 at 13:03
  • \$\begingroup\$ Does it print without confirmation? No? Well too bad, it's invalid. \$\endgroup\$ Commented May 30, 2017 at 21:39
  • \$\begingroup\$ @CalculatorFeline Why the hostility? If you read the footnote of the challenge you'd see "...Existing answers that do this as of 10:48am PST 31st Dec 2016 will be grandfathered...". \$\endgroup\$ Commented May 30, 2017 at 23:40
  • \$\begingroup\$ Oh. I missed that part. \$\endgroup\$ Commented May 30, 2017 at 23:50
2
\$\begingroup\$

c#, (削除) 259 (削除ここまで) 250 bytes

using System.Drawing;using System.Drawing.Printing;struct p{static void Main(){var p=new PrintDocument();p.PrintPage+=(s,e)=>e.Graphics.DrawString("Hello,World!",new Font("Arial",12),new SolidBrush(Color.Black),new Rectangle(0,0,999,99));p.Print();}}

Example output

answered Apr 22, 2017 at 6:06
\$\endgroup\$
2
\$\begingroup\$

Batch, 32 bytes

echo Hello, World!>t
notepad/P t

Should work on all versions of windows with no manual intervention required.

answered May 3, 2017 at 17:50
\$\endgroup\$
2
\$\begingroup\$

APL (Dyalog), 50 bytes

Of course we could shell out and use a Batch/Bash solution, but let us instead create a real print job:

{'X.'⎕WC'Text' 'Hello, World!'⍵⊣'X'⎕WC'Printer'}⍳2

⎕WC is Windows Create object

First we create a printer object (a print job) called 'X', then () in that ('X.') we create a text object at the argument of the anonymous function {...}. The argument is ⍳2, which gives the first two integers (1 2) and means 1% from the top and 2% from the left. When the anonymous function terminates, all its local variables (X) are destroyed, which signals to Windows that the print job is ready to be printed:


Print job

answered Jun 7, 2017 at 23:32
\$\endgroup\$
2
\$\begingroup\$

Ruby, 55 bytes

IO.write(?l,"Hello, World!");`lpr<<?l`

For Mac and Linux, your default printer must be set at localhost:631.

For Windows, you need to add an lpr port in your printer settings.

answered Aug 7, 2020 at 8:44
\$\endgroup\$
3
  • \$\begingroup\$ No need to write to file; you can just send the string to lp directly: `lp<<<Hello,\ World!` \$\endgroup\$ Commented Aug 14, 2020 at 2:02
  • \$\begingroup\$ I figured everyone was doing that, so I just used lpr. Thanks for the advice. \$\endgroup\$ Commented Aug 14, 2020 at 2:30
  • \$\begingroup\$ Admittedly it is boring. There are a few ways to golf your version: File.write -> IO.write, you can remove mode:?w, and you can use backticks instead of system. \$\endgroup\$ Commented Aug 14, 2020 at 2:36
2
\$\begingroup\$

Python 3 (Win32), 114 bytes

I used the win32api library to do this.

import win32api;open('h.txt', 'w').write('Hello, World!');win32api.ShellExecute(0, 'print', 'h.txt', None, '.', 0)
answered Dec 9, 2020 at 17:33
\$\endgroup\$
1
\$\begingroup\$

Racket 35 bytes

(system("echo 'Hello World!'\|lp"))
answered Dec 31, 2016 at 13:00
\$\endgroup\$
1
\$\begingroup\$

ZPL (Zebra Programming Language), 25 bytes

Code:

^XA^FDHello, World!^XZ~PS

Try it online!

Explanation:

^XA # Start Format
 ^FDHello, World! # Field Data "Hello, World!"
^XZ # End Format
~PS # Print Start
answered Apr 22, 2017 at 6:05
\$\endgroup\$
1
\$\begingroup\$

Lua, (削除) 34 (削除ここまで) 32 bytes

os.execute"lp<<<'Hello, World!'"
answered May 28, 2021 at 20:56
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice first answer! Be sure to check out Tips for golfing in Lua for further help on golfing your answers. \$\endgroup\$ Commented May 29, 2021 at 21:44
  • 1
    \$\begingroup\$ Thanks for the tips! Managed to scrape off 2 bytes from my original answer :) \$\endgroup\$ Commented May 29, 2021 at 22:53
1
\$\begingroup\$

HP‐41C series, 44 Bytes

Because this program uses accumulated printer output (ACA), the printer’s print mode must be set to man (manual). In trace or norm (normal) mode the print buffer is printed prematuraly, thus not producing the desired result. This preparation cannot be programmed.

01♦LBL⸆P 5 Bytes global label requires 4 + n Bytes
02 ⸆H 2 Bytes set alpha register to the string "H"
03 ACA 2 Bytes accumulate alpha register contents
04 ⸆ELLO, 6 Bytes overwrite alpha register again
05 SF 13 2 Bytes sets lower case flag
06 ACA 2 Bytes accumulate α‐register and translate to lowercase
07 ⸆ W 3 Bytes
08 CF 13 2 Bytes disable lowercase translation
09 ACA 2 Bytes
10 ⸆ORLD 5 Bytes exclamation point cannot be entered via keyboard
11 33 2 Bytes put character code for `!` into `X` register
12 XTOA 2 Bytes append character identified by `X` to α‐register
13 SF 13 2 Bytes
14 ACA 2 Bytes
15 PRBUF 2 Bytes print contents of printer buffer and clear it
16 END 3 Bytes

−1 B: You can use the command ADV (1 Byte) instead of PRBUF (2 Bytes). The print buffer procedure starts printing from the left‐hand margin. The advance procedure prints the buffer right justified.

−2 B: The END command allows inspecting the program’s size via catalog 1 and forms a barrier for local label search. A RTN (1 Byte) does not have said characteristics.

Let’s see the program in action: Note, the video actually shows a program with a couple ADV inserted before the END.
PS: Yeehaw! This is my 100th (programming challenge answer) post!

answered Mar 30, 2024 at 10:00
\$\endgroup\$
0
\$\begingroup\$

HTML (33)

Hello, World!<svg onload=print()>

(Prompts a print window in the browser, doesn't print directly)

answered Dec 31, 2016 at 7:02
\$\endgroup\$
3
  • \$\begingroup\$ Is there a reason the tag has to be <svg> specifically, or would any tag work? (Many tags have shorter names.) \$\endgroup\$ Commented Dec 31, 2016 at 9:00
  • 8
    \$\begingroup\$ afaik, only svg, img (with a valid src), iframe and body have an onload event triggered when the page is loaded. img without src triggers an onerror event. all in all, the shortest we've found is svg onload=... \$\endgroup\$ Commented Dec 31, 2016 at 13:02
  • \$\begingroup\$ The challenge asks for upper case W (not that it changes your byte count). \$\endgroup\$ Commented Dec 31, 2016 at 13:23
0
\$\begingroup\$

JavaScript + HTML, 20 bytes

print()
Hello, World!

answered Apr 22, 2017 at 6:43
\$\endgroup\$
1
  • \$\begingroup\$ This just opens the print dialog. Further manual intervention is required to actually print. Please see the note at the bottom of the question. \$\endgroup\$ Commented Apr 22, 2017 at 21:05
0
\$\begingroup\$

C#, 174 bytes

namespace System.Drawing.Printing{_=>{var p=new PrintDocument();p.PrintPage+=(s,e)=>e.Graphics.DrawString("Hello, World!",new Font("Onyx",9),Brushes.Black,0,0);p.Print();};}

Full/Formatted version:

namespace System.Drawing.Printing
{
 class P
 {
 static void Main(string[] args)
 {
 Action<float> f = _ =>
 {
 var p = new PrintDocument();
 p.PrintPage += (s, e) =>
 e.Graphics.DrawString("Hello, World!", new Font("Onyx", 9), Brushes.Black, 0, 0);
 p.Print();
 };
 f(0);
 }
 }
}
answered May 23, 2017 at 11:30
\$\endgroup\$
-1
\$\begingroup\$

Javascript, 36 bytes

print(document.write`Hello, World!`)
answered Jan 2, 2017 at 15:16
\$\endgroup\$
1
  • 1
    \$\begingroup\$ This just opens the print dialog. Further manual intervention is required to actually print. Please see the note at the bottom of the question. \$\endgroup\$ Commented Apr 22, 2017 at 21:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.