Post Reply 

file-pdf-load in Windows

Feb 7, 2012, 09:27
Post: #1
file-pdf-load in Windows
Hi,

Relatively new to GIMP but been playing with it for a couple of days and one thing is really frustrating me. I can't seem to open PDF's in batch mode via a script. JPG's are fine but PDF's just won't load, I always get:
"Execution error for procedure 'gimp-file-load':
Could not convert '1.pdf' to an URI: The pathname '1.pdf' is not an absolute path"

Tried this with file-pdf-load but get exactly the same error. Any ideas? Is this just a limitation of doing this in Windows?

Also, anyone know a way around using full file paths in windows? The \ aren't being picked up.

Thanks,
Andy

Code:
(define (batch-crop-jpeg)
(let* ((filelist (cadr (file-glob "*.pdf" 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE
filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(plug-in-autocrop RUN-NONINTERACTIVE
image drawable)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))
Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 10:21
Post: #2
RE: file-pdf-load in Windows
Given the message it expects a full path "c:\users\johndoe\my documents\thebloodyfile.pdf". You may have to prefix the file names or the search pattern in file-glob) with the current directory.

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 12:18
Post: #3
RE: file-pdf-load in Windows
Hi, thanks for this.

That was the issue. I had tried the full file path before but \ didn't seem to be working. Resorted to using / instead and that works. Odd that it seems to work differently for PDF's than JPG's.
Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 12:34
Post: #4
RE: file-pdf-load in Windows
It's going to be entirely dependent on the PDF file loader as that is what gimp-file-load uses.

By the way, if you're building the full file path yourself, then you should use the DIR-SEPARATOR constant and not explicitly use "/" or "\\" as DIR-SEPARATOR evaluates to the correct value dependant on the operating system and makes your code platform independent.
Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 13:41
Post: #5
RE: file-pdf-load in Windows
(Feb 7, 2012 12:34)paynekj Wrote:  It's going to be entirely dependent on the PDF file loader as that is what gimp-file-load uses.

By the way, if you're building the full file path yourself, then you should use the DIR-SEPARATOR constant and not explicitly use "/" or "\\" as DIR-SEPARATOR evaluates to the correct value dependant on the operating system and makes your code platform independent.
At the API level, all systems understand the "/" as a separator, even Windows, where "\" is really a command line parser issue (and a major pain for us AZERTY users). You can try this in Windows;

Code:
# create x and y directories
mkdir x\y
# list
dir x\y
# this complains : Invalid switch - "y".
dir x/y
# but with quotes this is OK
dir "x/y"

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  GAP Plugin error windows 8.1gap_ decode_mplayer.exe entry point not found. thegreenman 1 687 Sep 8, 2014 11:55
Last Post: rich2005
Question Load PDF and load images Vash Stampida 2 433 Aug 7, 2014 20:05
Last Post: Vash Stampida
  Windows 8, GIMP 2.8.10, crashes opening files or on new but will open by itself. Coanunn 2 367 Jul 29, 2014 13:57
Last Post: Coanunn
  How to get python module to load? Michael the Narwhal 1 642 Apr 16, 2014 17:05
Last Post: ofnuts
  Batch conversion of PDF file ? eljay 7 6,245 Oct 21, 2013 10:20
Last Post: almien

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS