Printing HTML from command line returns blank document


Greetings, I've downloaded the latest version of PDFCreator (3.4.0). When I try printing a HTML file with any profile (autosave, since I'll need to attach it to an application), if I do it from the GUI it works correctly, but running

"C:\Program Files\PDFCreator\PDFCreator.exe" /PrintFile="Desktop\test.html"

I obtain a blank PDF file in the with right path and name but only displaying title and "page 1 of 1".
I've also tried some of CL parameters specified in documentation, but nothing changes and however the default value for those parameters is fine. Maybe this is a bug? Or maybe there should be a parameter to specify input type?



for the working case, did you use the PDFCreator GUI or did you print the html from a browser manually?
The PrintFile command will just lookup how to print the type of file in your registry and execute the command it finds. It should be the same as right clicking onto the file and selecting "print" from the context menu. Setting a different default browser or changing the browsers printing settings might solve the issue.

Best regards



Hello, I've just tried this:

  • launching print from cmd with the string above (which I've just corrected) prints a blank file;
  • printing from GUI prints the file correctly;
  • printing from default browser (firefox) prints correctly (even better, because it breaks the pages in a smarter way).

I've also tried running

"C:\Program Files\PDFCreator\PDFCreator.exe" /PrintFile="C:\Users\DeRAn\Desktop\test.html"

and after that I'm getting a dialog telling me that file cannot be converted. Even by running the previous string. I'm quite confused now.

The html file is a xml + xslt file "compiled" by Saxon lib.



sorry for the trouble, I am also a bit confused now.
If the file is located at C:\Users\DeRAn\Desktop\test.html, the initial command "C:\Program Files\PDFCreator\PDFCreator.exe" /PrintFile="Desktop\test.html" shouldn't have produced anything unless ran from C:\Users\DeRAn, in which case it should have the same result for both cases. If I point the command to a none existing file on my machine, PDFCreator doesn't run at all (as expected).

Using the command line and the GUI should also produce the same result, how exactly did you "print from the GUI"? Did you run the PDFCreator.exe and use the "Choose a file to convert" button, or drag & drop, or the context menu entry?
Setting the logging level to "trace" inside the application settings might also help to find the cause of this issue.

Best regards



So, now I'm getting the "file cannot be printed" error from both GUI and command line, but I can print it from browser by selecting PDFCreator printer and it works fine. I believe this happens since I've printed from browser for the first time.
The file path was right, I was in the user directory when I first launched the print with command line. I've tried to enter full file path to see if something changed, But I had already printed from browser and so I got the error.


It might be possible to fix this issue by specifying a different command for printing html in your registry.
First, check the value of the (Standard) key inside Computer\HKEY_CLASSES_ROOT\.html
In my case it is htmlfile and I will assume it is the same for you for the rest of the explanation.
Now check Computer\HKEY_CLASSES_ROOT\htmlfile\shell - there should be a "print" and a "print to" subfolder here. If there isn't, PDFCreator doesn't know how to print the file and will display the "File cannot be printed" error message. You could however create Computer\HKEY_CLASSES_ROOT\htmlfile\shell\printto\command
and enter any command capable of printing html as its standard value. On my system, this is
"C:\WINDOWS\system32\rundll32.exe" "C:\WINDOWS\system32\mshtml.dll",PrintHTML "%1" "%2" "%3" "%4"
but it isn't very useful as it actually opens a printer selection dialogue.

Best regards



Printing file using that command still prints the empty file. I've also tried to follow your instructions about reg keys but nothing has changed - it still says it's unable to convert document.
I've taken a look at this immagine

but I didn't manage to make that work with PDFCreator: the first solution on that post tells me a print job has been added but nothing is printed, then if I try again it can't find the printer (I saw PDFCreator printer is on port pdfcmon); the second solution breaks the software and I have to reinstall it to get it back to work.



the printing /port assignment is not the issue, otherwise it wouldn't be possible to convert anything.
The issue is specific to the html file type and how its printing commands are registered on your system.
If running the command "C:\WINDOWS\system32\rundll32.exe" "C:\WINDOWS\system32\mshtml.dll",PrintHTML "%1" "%2" "%3" "%4" produces an empty file when pointed to the PDFCreator printer, the mshtml.dll is actually sending the empty page and a hardware printer would also end up with a blank page.
If there is any string inside HKEY_CLASSES_ROOT\htmlfile\shell\printto\command and .html is associated with "htmlfile" in your registry, I however don't understand how PDFCreator can then output the "Unable to convert document" error message, as this is directly tied to checking this registry location.

Best regards