Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to write the pdf to a specific place ? #11

Open
jonathanBieler opened this issue May 4, 2017 · 0 comments
Open

Is there a way to write the pdf to a specific place ? #11

jonathanBieler opened this issue May 4, 2017 · 0 comments

Comments

@jonathanBieler
Copy link
Contributor

It doesn't seem to be the case, opening it is nice but when you run a script you rather want to write the pdf somewhere silently. I would do something like that:

function makepdf(latex)
    dirname = "$(tempname()).d"
    mkdir(dirname)
    texname = joinpath(dirname, "document.tex")
    pdfname = joinpath(dirname,"document.pdf")
    open(texname, "w") do file
        write(file, latex)
    end
    cd(dirname) do
        for i in 1:2
            output = readall(`pdflatex -shell-escape -halt-on-error $texname`)
            contains("Error:", output) && println(output)
        end
    end
    pdfname
end

function writepdf(latex,filename)
    pdfname = makepdf(latex)
    cp(pdfname,filename,remove_destination=true)
    nothing
end


function openpdf(latex)
    pdfname = makepdf(latex)

    if OS_NAME == :Windows
        command = "cmd /K start \"\" $pdfname"
        CreateProcess(command)
    else
        spawn(`open $pdfname`)
    end
    pdfname
end

I can do a PR if you want.

@jonathanBieler jonathanBieler changed the title Is there a way to write the pdf to a specific place. Is there a way to write the pdf to a specific place ? May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant