[Gimp-user] Cannot use function file-pdf-save-multi



        Hello,
        I am having a problem with function file-pdf-save-multi().

# What I am trying to do

I am trying to render a list of several XCF files into a single PDF,
each XCF file being rendered as a page of the output document. I have a
first version, which works, but it uses file-pdf-save() to make one PDF
file per XCF source file, and assembles them afterward using another
program. As I am writing this script for some other people, some using
GNU/Linux, and some Mac OS, I would like to keep the list of
dependencies as small as possible. So if I could manage to make it pure
GIMP (and sh), it would be perfect.

# The (non-working) script

The core part of my script is given at the end of this message. It
provides two versions :
- the first one takes a single XCF file and converts it to PDF, using
file-pdf-save(). It works, but I would prefer the following one to work:
- the second one takes several XCF (actually, twice the same in this
dummy version), and converts them as a two-pages PDF, each source XCF
being one page of the PDF, using function file-pdf-save-multi(). It does
not work, the output being :

    ts> Create multipage PDF-Warning: An error occured while creating
the PDF file:
    error while writing to output stream
    Make sure you entered a valid filename and that the selected
location isn't read only!

    Error: Procedure execution of file-pdf-save-multi failed


# Error analysis

The error message is weird: I looked at the source code of the two
functions I use (file-pdf-save and file-pdf-save-multi), and the way the
output file is handled seems to be the same. However, although the first
one succeeds, the second one fails, saying that maybe the location is
read only (which is not the case).
http://git.gnome.org/browse/gimp/tree/plug-ins/common/file-pdf-save.c

# My question

I could not find on the Internet any example of file-pdf-save-multi()
being used. The only documentation I found was the GIMP documentation,
which was not sufficient for me to use it. Can you help me to use this
function?

Regards,
Louis

==================== Script ==================================

#!/bin/bash
# Usage: script_name.sh file.xcf
# Expected behavior:
# 1) creates output_simple.pdf as the PDF version of the argument
# 2) creates output_multi.pdf as a PDF containing two pages,
#    each of which being a PDF version of the argument.
# Actual behavior:
# 1) works
# 2) fails, and I wonder why.
#
# I hope my email agent did not messed up two much with lines breaks...

input=$1
output_base="output"

echo "### Using file-pdf-save"
echo "\
    (let* \
        ( \
          (image (car (gimp-file-load RUN-NONINTERACTIVE \"$input\"
\"$input\"))) \
          (drawable (car (gimp-image-merge-visible-layers image
CLIP-TO-IMAGE)))  \
        ) \
        (file-pdf-save RUN-NONINTERACTIVE image drawable
\"${output_base}_simple.pdf\" \"${output_base}_simple.pdf\" TRUE TRUE
TRUE) \
    ) \
    (gimp-quit 0)" | \
    gimp -i -b -

echo "\n###############"
echo "### Using file-pdf-save-multi"

echo "\
    (let \
        ( \
            (images (cons-array 2 'double)) \
        ) \
        ( \
            (aset images 0 (car (gimp-file-load RUN-NONINTERACTIVE
\"$input\" \"$input\"))) \
            (aset images 1 (car (gimp-file-load RUN-NONINTERACTIVE
\"$input\" \"$input\"))) \
            (file-pdf-save-multi RUN-NONINTERACTIVE images 2 TRUE TRUE
TRUE \"${output_base}_multi.pdf\" \"${output_base}_multi.pdf\") \
        ) \
    ) \
    (gimp-quit 0)" | \
    gimp -i -b -



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]