Giter Site home page Giter Site logo

Comments (7)

QikeLi avatar QikeLi commented on July 2, 2024 1
  1. Looks like your R code should be generating the pdf. Are you sure that the pdf is being generated before the org-export-before-processing-hook? Because that is when the pdf file should be available if you are using that hook. To test out this theory, use a pre-generated pdf like the one I have in my mwe, and use that instead of relying on R to generate the pdf.

I thought about that too. But no, this is no what's causing the problem.

  1. I do not think this second point could be causing the problem, but still I'll list it. The #+HEADER is actually an org inbuilt feature for source blocks. I am reusing it for this pdf to png conversion feature.

I am glad you raised this point. Once I place =#+HEADER: :convertfrompdf t= right before the figure[[*.png]], everything works fine.

Thank you for your quick response and this awesome function!

from .emacs.d.

kaushalmodi avatar kaushalmodi commented on July 2, 2024

I just added a minimum working example in https://github.com/kaushalmodi/.emacs.d/tree/master/elisp/org-include-img-from-pdf

Check it out.

Use the same mwe org file ( https://raw.githubusercontent.com/kaushalmodi/.emacs.d/master/elisp/org-include-img-from-pdf/org-include-img-from-pdf-mwe.org ) and the associated PDF file and see if it works for you.

from .emacs.d.

QikeLi avatar QikeLi commented on July 2, 2024

Thank you very much for the mwe. It worked perfectly for me. However, I realized that if a figure is not placed at the beginning of the file like what you did, it cannot get converted. Does that happen to you as well? If so, do you plan to fix it?

Here is my example you may want to use to reproduce the error.

    #+TITLE: PDF Image
    #+NAME: fig:unicorn
    #+HEADER: :convertfrompdf t
    
    1. make a plot
    
    #+BEGIN_SRC R :exports both :results graphics :file ./fig-1.pdf 
    plot(1:100)
    #+END_SRC
    
    [[./fig-1.png]]

from .emacs.d.

kaushalmodi avatar kaushalmodi commented on July 2, 2024

However, I realized that if a figure is not placed at the beginning of the file like what you did, it cannot get converted.

That should have worked as long as the pdf file was available.

I do not have R installed so I tried the below and that worked:

#+TITLE: PDF Image

#+NAME: fig:unicorn
#+HEADER: :convertfrompdf t

1. make a plot

[[./org-mode-unicorn-logo.png]]

Though, I am not sure why you would want to keep the #+NAME and #+HEADER related to that image away from the image reference.

Few things I could think of that could be causing the problem:

  1. Looks like your R code should be generating the pdf. Are you sure that the pdf is being generated before the org-export-before-processing-hook? Because that is when the pdf file should be available if you are using that hook. To test out this theory, use a pre-generated pdf like the one I have in my mwe, and use that instead of relying on R to generate the pdf.
  2. I do not think this second point could be causing the problem, but still I'll list it. The #+HEADER is actually an org inbuilt feature for source blocks. I am reusing it for this pdf to png conversion feature.

from .emacs.d.

kaushalmodi avatar kaushalmodi commented on July 2, 2024

Once I place =#+HEADER: :convertfrompdf t= right before the figure[[*.png]], everything works fine.

Glad to know that you have this working. Yeah, that #+HEADER is supposed to be specific to each figure. So it's not a bad idea to have #+HEADER directly before the figure (along with #+NAME and #+CAPTION if any).

Feel free to close this issue if that is workable for you.

from .emacs.d.

kaushalmodi avatar kaushalmodi commented on July 2, 2024

Started a discussion on org mode list to learn about the best way to improve this: http://lists.gnu.org/archive/html/emacs-orgmode/2017-01/msg00260.html

from .emacs.d.

kaushalmodi avatar kaushalmodi commented on July 2, 2024

Done in db69815.

from .emacs.d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.