0

Windows 7

I generated a pdf using wkhtmltopdf in C:/Program Files/wkhtmltopdf/bin with the command wkhtmltopdf http://google.co.uk google.pdf to test it out.

However, google.pdf does not show in Windows Explorer and running ls -l shows it but running dir does not... Why would the file be invisible in this way?

Edit

Running cat google.pdf prints the pdf to the terminal

I also found I can copy the file to another directory - with exactly the same issues with the copy of the file in its new directory.

Looking at the permissions from ls -l - noone has execute permission for the pdf file. I don't know whether that is important though. This isn't important - other pdf's on my computer have the same set of permissions.

Result of attrib google.pdf in C:/Program Files/wkhtmltopdf/bin

attrib google.pdf
File not found - google.pdf

Result of ls -l in C:/Program Files/wkhtmltopdf/bin

total 64957
-rw-r--r--  1 Admin  Administ   305109 Jul  1 14:59 bbc.pdf
-rw-r--r--  1 Admin  Administ    30426 Jul  1 15:28 google.pdf
-rwxr-xr-x  1 Admin  Administ   489773 Jun 17 10:54 libgcc_s_sjlj-1.dll
-rwxr-xr-x  1 Admin  Administ  6762827 Jun 17 10:54 libstdc++-6.dll
-rwxr-xr-x  1 Admin  Administ   243109 Jun 17 10:54 libwinpthread-1.dll
-rwxr-xr-x  1 Admin  Administ 41729536 Jun 17 10:54 wkhtmltoimage.exe
-rwxr-xr-x  1 Admin  Administ 41827328 Jun 17 10:53 wkhtmltopdf.exe
-rwxr-xr-x  1 Admin  Administ 41639424 Jun 17 10:52 wkhtmltox.dll
9
  • Are you running both ls and dir against the same location? Where is the file stored? On a file server, or are you copying it from a Linux machine to Windows? – Adam Thompson Jul 1 '15 at 14:33
  • The file is stored in C:/Program Files/wkhtmltopdf/bin - the same directory I am running these commands from. This is all within that folder on my WIndows machine (I have ls and other commands available from my installation of Git for Windows) – Kvothe Jul 1 '15 at 14:35
  • @AdamThompson I've just found that no-one has execute permissions on the pdf (from running ls -l). Could that be the problem? – Kvothe Jul 1 '15 at 14:38
  • Is it cygwin ls you're using on Windows, or something else? From the command prompt, can you cd to the directory with the file and run attrib google.pdf, and post the results here, please? – Adam Thompson Jul 1 '15 at 14:57
  • Could you, please post the output of ls -l from inside C:/Program Files/wkhtmltopdf/bin – Art Gertner Jul 1 '15 at 14:59
3

Assuming that the attributes are set correctly (ie the file is not set as 'hidden' or 'system'), this is probably the result of a non-elevated program attempting to write to the %ProgramFiles% structure.

When non-elevated programs attempt to write to this directory structure, they will end up writing to %LocalAppData%\VirtualStore.
For example, if the application unelevated.exe attempts to write to C:\Program Files\Unelevated\file.txt, it will actually write to C:\Users\Bob\AppData\Local\VirtualStore\Program Files\Unelevated\file.txt.

Other applications may also end up at the VirtualStore location, depending on how they've been compiled.

This may or may not be fixed in later versions of MinGW.

3
  • Thanks! You've saved me a major headache. I don't suppose you know whether the same thing would happen if wkhtmltopdf were installed on a webserver? Thank you once again! – Kvothe Jul 1 '15 at 15:19
  • If the webserver is running Windows Server 2008 or later, it will run the process virtualised. If you mean that the web server would create the file, and the client would download it using a web browser, then it will work just the same as if the web browser was downloading any other file from anywhere else. Best thing to do is to not use the application to write to the %ProgramFiles% structure. Either write the file to your Documents folder, or setup some other folder on your PC/webserver (eg C:\GeneratedPDFs) and write the files to that. – Adam Thompson Jul 1 '15 at 15:22
  • Excellent. Thank you so much for your help with this! – Kvothe Jul 1 '15 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.