5

I want to open PDF using PDF-XChange Viewer through WINE. How should I specify the pdf file name in the "custom command" line so that I can open a PDF file using PDF-XChange Viewer by double clicking it? I tried to use the \"z:%f\" following the suggestion here for using Foxit reader. But my PDF-XChange Viewer only starts with an empty window.

wine "c:/Program Files/Tracker Software/PDF Viewer/PDFXCview.exe" \"z:%f\"

I use Ubuntu 10.04 and WINE 1.2.2. PDF-XChange Viewer version 2.5.

5
  • I suspect you need "c:/Program\ Files/Tracker\ Software/PDF\ Viewer/PDFXCview.exe" Apr 18, 2012 at 10:14
  • No, he does not, the "" are used for that... Apr 18, 2012 at 11:11
  • Bruno Pereira is right, I could actually start PDF-XChange Viewer if I double click on a PDF file. But the file is not opened, only the program is executed. Obviously the file name is not passed successively to the PDF viewer.
    – HongboZhu
    Apr 18, 2012 at 11:18
  • Thiy this: wine `"C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" z:"%f"`
    – lukasz
    Apr 18, 2012 at 11:38
  • @lukasz: the backticks cause the PDF viewer fail to even start.
    – HongboZhu
    Apr 18, 2012 at 11:47

6 Answers 6

3

Found blog entries about the same problem for Foxit reader and for PDF-XChange Viewer. None of them worked for me. So I edited them and got one tailored for my case:

#!/bin/bash  
Filename="z:${1//\//\\}"
wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" $Filename

Save this bash script and open pdf using this script. Now double click pdf files will open them using PDF-XChange Viewer.

3

If the script works then you should accept that answer even though it was your own.

What has worked here for other apps as far as a custom command was close to what you were trying, some small differences.

wine "C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" Z:%f

Referenced here for photoshop with add. info on altering the display name if desired for right click use - http://ubuntuforums.org/showpost.php?p=9193687&postcount=9

1

This is based on @Flint's excellent script.

At first I tried "Z:"%U variable at the end of desktop file Exec= field for Wine programs. It worked fine until I opened a program without a file specified. Wine programs complained about missing file because the Exec= line pointed to the drive Z: which clearly is not a file but absolute file path instead. File not found: Z: or similar messages popped up in a Wine program. Bit annoying.

Problem with "Z:"%U is that it's not a conditional variable if Z: is used there. However, Wine absolutely requires Z: because it can't find correct file paths otherwise.

Your script makes the whole "Z:"%U thing a conditional clause. The script does the job exactly as I've wished for.

However, the script should consider all exe files written in uppercase, too. By now, it can't point any MS Office files (docx, pptx...) to MS Office 2010 because all program executables are written like WINWORD.EXE or POWERPNT.EXE. Of course executables could be renamed in lower case but I prefer more universal solution rather than renaming single exe's for every program.

Dirty and universal solution is to modify the script code like:

#!/bin/bash

allargs=("$@")

fixpath=0
for idx in "${!allargs[@]}"; do
    arg="${allargs[$idx]}"

    if [[ $fixpath -eq 0 ]]; then
        # fix file paths only after the first executable is found in arg
        if [[ "$arg" == *.exe ]]; then
            fixpath=1
        fi
        if [[ "$arg" == *.EXE ]]; then
            fixpath=1
        fi
        continue
    elif [[ $fixpath -eq 1 ]]; then
        # if arg starts with '/' and it's a path that exists on host
        # precede the path with drive 'Z:'
        if [[ "${arg:0:1}" == '/' && -e "$arg" ]]; then
            allargs[$idx]="z:${arg//\//\\}"
        fi
    fi
done

exec env "${allargs[@]}"

The or operator did not work for some reason. I'm sure there is a more elegant way to achieve same result, anyway.

0

If that program already installed using wine then I dont think it needs absolute path. I think only

 wine pdfxcview filename

will open the file.

Okay may be my reply is stupid. What actually you are trying to do ? are you trying to fix the program launch error ?

1
  • No, I did not have problem starting the pdf viewer. I guess I did not state the question clearly (I have revised the question now). I want to know how to specify input files in "custom command" s.t. when I double click a file it will be opened by pdfxcview.
    – HongboZhu
    Apr 18, 2012 at 11:51
0

I realize this is old question but I want to share my solution which I figured after having started using PDFXchangeEditor (successor to PDFXchangeViewer) then bumped into issue to make it accepts multiple input files from host os. First of all, the accepted answer and all other answers which have been posted assume that the program will only handle a single file. You can actually throw multiple file args at once to it and it will open them all fine, with a little trick.

The trick is using %F code expansion in Exec field in the app's .desktop launcher and preceed all the expanded local file args in the field with Z: which can be done with the following script

Call it wine-env. This goes in /usr/local/bin and be sure to give it chmod +x

#!/bin/bash

allargs=("$@")

fixpath=0
for idx in "${!allargs[@]}"; do
    arg="${allargs[$idx]}"

    if [[ $fixpath -eq 0 ]]; then
        # fix file paths only after the first executable is found in arg
        if [[ "$arg" == *.exe ]]; then
            fixpath=1
        fi
        continue
    elif [[ $fixpath -eq 1 ]]; then
        # if arg starts with '/' and it's a path that exists on host
        # precede the path with drive 'Z:'
        if [[ "${arg:0:1}" == '/' && -e "$arg" ]]; then
            allargs[$idx]="Z:$arg"
        fi
    fi
done

exec env "${allargs[@]}"

And for the app's .desktop file, call it pdfxce.desktop and put it in ~/.local/share/applications/ and its content should look like this

[Desktop Entry]
Name=PDF-XChange Editor
Type=Application
Terminal=false
Exec=wine-env WINEDEBUG=-all WINEPREFIX=/home/<user>/.local/share/bottles/pdfxce wine PDFXEdit.exe %F
Icon=/home/<user>/.local/share/icons/bottles/pdfxce-pdfxedit.png
Path=/home/<user>/.local/share/bottles/pdfxce/drive_c/Program Files/Tracker Software/PDF Editor
StartupNotify=true
StartupWMClass=PDFXEdit.exe

You need to change the part with your own username. I keep all of my wineprefixes dirs in a folder called "bottles". You may have your own way to organize your wineprefixes so change all the parts that contain "bottles" accordingly

And last step, assign PDF files to the app as per normal (Right click on pdf -> Properties -> Open With tab)

Reference: Freedesktop's desktop entry specification

0

I followed this link to install 32 bit PDF XChange viewer in Ubuntu 64 Bit 14.04 Then the link shows a script to open the PDF Xchange viewer with the file-name as argument. I made that script and kept that in /bin

Then I edited the ~/.local/share/applications/wine-extension-pdf.desktop to this:

[Desktop Entry]
Type=Application
Name=PDF-XChangeViewer
MimeType=application/pdf;
Exec=PDFXCview %f
NoDisplay=true
StartupNotify=true

My script was named PDFXCview

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .