ashafaei / pdf2pptx

Convert your (Beamer) PDF slides to (Powerpoint) PPTX
MIT License
371 stars 88 forks source link

Doesn't work on OSX, need to change sed flag #1

Closed joschu closed 5 years ago

joschu commented 7 years ago

I got a bunch of errors on OSX saying "invalid command code..." Fixed by switching -i to -i '' based on this stackoverflow post: http://stackoverflow.com/questions/7573368/in-place-edits-with-sed-on-os-x Thanks for posting this great tool!

diff --git a/pdf2pptx.sh b/pdf2pptx.sh
index 75202f9..d65570e 100755
--- a/pdf2pptx.sh
+++ b/pdf2pptx.sh
@@ -52,19 +52,19 @@ function add_slide {
        id=$((id+8))
        entry='<Relationship Id=\"rId'$id'\" Type=\"http:\/\/schemas\.openxmlformats\.org\/officeDocu
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../_rels/presentation.xml.rels
+       sed -i '' "s/${pat}/${rep}/g" ../_rels/presentation.xml.rels

        pat='slide1\.xml\" ContentType=\"application\/vnd\.openxmlformats-officedocument\.presentatio
        entry='<Override PartName=\"\/ppt\/slides\/slide-'$1'\.xml\" ContentType=\"application\/vnd\.
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../../\[Content_Types\].xml
+       sed -i '' "s/${pat}/${rep}/g" ../../\[Content_Types\].xml

        sid=$1
        sid=$((sid+256))
        pat='<p:sldIdLst>'
        entry='<p:sldId id=\"'$sid'\" r:id=\"rId'$id'\"\/>'
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../presentation.xml
+       sed -i '' "s/${pat}/${rep}/g" ../presentation.xml
 }

 function make_slide {
@@ -84,7 +84,7 @@ done
 if [ "$makeWide" = true ]; then
        pat='<p:sldSz cx=\"9144000\" cy=\"6858000\" type=\"screen4x3\"\/>'
        wscreen='<p:sldSz cy=\"6858000\" cx=\"12192000\"\/>'
-       sed -i "s/${pat}/${wscreen}/g" ../presentation.xml
+       sed -i '' "s/${pat}/${wscreen}/g" ../presentation.xml
 fi
 popd
ashafaei commented 7 years ago

Hello @joschu

Thanks for taking the time to resolve this issue and thanks for reporting it to me. I'll apply your fix.

Cheers. PS> I enjoyed your tutorial last week.

joschu commented 7 years ago

Hah, funny coincidence that you were at my talk -- glad you liked it!

myildi commented 6 years ago

Thank you very much to both, for the very useful script and for the correction for OSX!

smeagolthellama commented 6 years ago

shouldn't this be a) closed or b) a pull request?

tddschn commented 5 years ago

I am on OSX (10.14.5).

After patching the original script using

patch < (your_diff_file_above)

I got a new file './pdf2pptx.sh.rej'

then I try to convert my pdf file '5FA.pdf' to a pptx file, I got this error message:

$ ./pdf2pptx.sh.rej 5FA.pdf
./pdf2pptx.sh.rej: line 1: 5FA.pdf: command not found
./pdf2pptx.sh.rej: line 2: 5FA.pdf: command not found
./pdf2pptx.sh.rej: line 15: p:sldIdLst: No such file or directory
./pdf2pptx.sh.rej: line 26: +: command not found
./pdf2pptx.sh.rej: line 29: Override: No such file or directory
./pdf2pptx.sh.rej: line 31: +: command not found
./pdf2pptx.sh.rej: line 34: 5FA: value too great for base (error token is "5FA")

I don't know how to solve this problem. can you help me? thanks in advance!

ashafaei commented 5 years ago

Hi @tddschn , I'm not sure what's going on. I think the new file you're trying to run may be corrupted during the process. The suggested change above is easy to apply, I'd recommend you do it manually.

There are four instances of sed -i that you should change to sed -i ''. Apprently OSX expects an empty string '' after the -i command. That's it.

ashafaei commented 5 years ago

The latest commit fixes this issue through a pull-request. I'm closing the issue.