Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • putpdf "failed to add paragraph" when saving

    I am using putpdf to save 2 .png files into one pdf document.

    Code:

    putpdf begin

    putpdf paragraph
    putpdf image enrollage.png
    putpdf image agedensity.png

    cd $final_graph
    //changing directory to where the final pdf will be saved
    putpdf save study_graphs.pdf
    putpdf clear


    At the point of "putpdf save" I get error r(198) which says "failed to add paragraph."

    I'm not trying to add a paragraph at this point in the code, I'm trying to save the pdf I've built-- why did this error show up and how can I fix it?

  • #2
    Welcome to Statalist.

    I think the message is trying to tell you that it was unable to put the completed paragraph into the document. The problem is that when you add your images to the paragraph, putpdf apparently does not read them at that time, but instead makes note of where they are. When you start a new paragraph, or save the pdf, it completes the construction of the previous paragraph. But in your case you changed your working directory before saving the completed pdf, so putpdf was unable to find the images in what had become the current working directory.

    Try removing the cd command and replacing the putpdf save with a reference to the full path to the final document
    Code:
    putpdf save $final_graph/study_graphs.pdf

    Comment


    • #3
      Thanks so much for getting back to me! I know the way I did the directory thing was funky, but it was because I couldn't get the syntax that you suggested above to work.

      My directories:
      gl indv_graphs ""/Volumes/leo/ORCA LIFT/De-Identified/Analysis/Graphs/individual graphs""
      gl final_graph ""/Volumes/leo/ORCA LIFT/De-Identified/Analysis/Graphs""


      When I run:
      putpdf save $final_graph/study_graphs.pdf

      I get error:
      invalid '/'
      r(198);


      When I run:
      putpdf save ${final_graph}study_graphs

      I get error:
      invalid 'study_graphs.pdf'
      r(198)
      ;

      I know this is a super minor syntax issue, but I appreciate it!

      Comment


      • #4
        Your globals have embedded spaces in them, so you need to surround the full path in quotation marks, and not the definition of the globals in two sets of quotation marks the way you did.
        Code:
        gl final_graph "/Volumes/leo/ORCA LIFT/De-Identified/Analysis/Graphs"
        putpdf save "$final_graph/study_graphs.pdf"
        or
        Code:
        gl final_graph "/Volumes/leo/ORCA LIFT/De-Identified/Analysis/Graphs"
        putpdf save "${final_graph}/study_graphs.pdf"

        Comment

        Working...
        X