markdown-to-pdf icon indicating copy to clipboard operation
markdown-to-pdf copied to clipboard

Image not rendering in the PDF

Open cr2007 opened this issue 2 years ago • 21 comments

As part of the discussion in #17, I tried the steps provided in the suggestions provided by the other users.

I also followed all the appropriate steps as provided in the documentation, but it is still not producing the images when the converted PDF file is released.

Here is the excerpt of the workflow:

# Code ....
  steps:
    # More Code...
      with:
        input_dir: Journals
        output_dir: pdf
        images_dir: Journals/images
        image_import: images

My markdown files are stored in Journal directory, and images are stored in Journal/images directory. I even tried adding single quotes over the directory names (string values), but it still wasn't rendering in that area.

This is the code that was added in the Markdown file:

<div align="center">
  <img src="./images/image.png" width="60%" />
</div>

Is there anything in particular I would need to fix this issue? Any help would be greatly appreciated.

cr2007 avatar Oct 02 '23 19:10 cr2007

To be precise, this is the error I get in the GitHub Action logs

Started image server with image folder route '/github/workspace/Journals/images'.

Markdown files found: Journal1.md
Converting: Journal1.md
Error: Invalid URI "./http://localhost:3000/Research%20Venn%20Diagram.png"
    at Request.init (/node_modules/request/request.js:273:31)
    at new Request (/node_modules/request/request.js:127:8)
    at request (/node_modules/request/index.js:53:10)
    at /node_modules/request/index.js:61:12
    at Function.get (/node_modules/request/index.js:100:12)
    at /markdown-to-pdf.js:67:[11](https://github.com/cr2007/F20PA-Project-Journal/actions/runs/6388946057/job/17339584384#step:4:12)
    at new Promise (<anonymous>)
    at encodeImage (/markdown-to-pdf.js:66:9)
    at MarkdownToPDF._convertImageRoutes (/markdown-to-pdf.js:238:23)
    at MarkdownToPDF.convert (/markdown-to-pdf.js:[14](https://github.com/cr2007/F20PA-Project-Journal/actions/runs/6388946057/job/17339584384#step:4:15)2:25)

cr2007 avatar Oct 03 '23 05:10 cr2007

Update: I tried to fix the Workflow, but it still isn't working.

THis is the current code:

# Previous code
            - name: Build PDF document
              uses: baileyjm02/markdown-to-pdf@v1
              with:
                input_dir: Journals
                output_dir: pdf
                images_dir: Journals/images
                # for example <img src="./images/file-name.png">
                image_import: ./images
                build_pdf: true
                build_html: false
# ...

I followed as per the Documentation provided, but it still doesn't work.

@BaileyJM02 if you kindly suggest the way to fix this, or let me know if it's alright to give you access to investigate what needs to be fixed.

cr2007 avatar Oct 03 '23 06:10 cr2007

@BaileyJM02 Is there any update on this?

cr2007 avatar Oct 15 '23 12:10 cr2007

@BaileyJM02

cr2007 avatar Oct 23 '23 04:10 cr2007

What is the current output / error since your last code change?

BaileyJM02 avatar Oct 23 '23 06:10 BaileyJM02

image

It only shows the broken image icon, and the alt text added to it.

I tried all the fixes suggested in previous issues, as well as writing it in Markdown instead of <img> tags, but it still shows the same error.

I don't get any error in the GitHub Actions logs now, but neither is the image being rendered either.

cr2007 avatar Oct 23 '23 06:10 cr2007

I'd be happy to give you access to the repository to show you how it works.

cr2007 avatar Oct 23 '23 06:10 cr2007

Sure, make sure to run the action outputting the HTML while we're debugging

BaileyJM02 avatar Oct 23 '23 06:10 BaileyJM02

In the above image, I've put both HTML and Markdown to show that both aren't rendering.

provided.

<div align="center">
  <img src="images/Research_Venn_Diagram.png" alt="Research Venn Diagram" width="60%" />
</div>

![Research Venn Diagram](images/Research_Venn_Diagram.png)

As shown in the above diagram, ...

image

cr2007 avatar Oct 23 '23 06:10 cr2007

Hey @BaileyJM02

Just wanted to follow-up on this issue. Were you able to debug the root problem?

cr2007 avatar Oct 27 '23 17:10 cr2007

@BaileyJM02

Update: I tried using v1.2.0 (latest) of the GitHub Action, and it is still not rendering

cr2007 avatar Oct 28 '23 06:10 cr2007

Troubleshooting local dev as I haven't touched the repo in a while. Once fixed will look into the issues you've raised.

BaileyJM02 avatar Oct 28 '23 18:10 BaileyJM02

Hey @BaileyJM02

Any update on this issue and #54 ?

cr2007 avatar Nov 06 '23 13:11 cr2007

@BaileyJM02

I have given you access to the repository. Do let me know if you are able to find the issue with the Action.

cr2007 avatar Nov 07 '23 15:11 cr2007

Thank you, that's super useful. I've allocated some time to debug this tomorrow - will get back to you on progress.

What's the deadline for submission for your work?

BaileyJM02 avatar Nov 07 '23 19:11 BaileyJM02

By this Friday I need to submit it. Mainly the issue is with Image Rendering and Task List (#54)

cr2007 avatar Nov 07 '23 19:11 cr2007

Unfortunately I've been looking into this for a few hours and haven't been able to resolve the issue. I've tried rolling back versions and all sorts. It might be that a dependancy has not followed semantic versioning and released a breaking change but I'm unable to investigate that far as I've ran out of time.

BaileyJM02 avatar Nov 08 '23 22:11 BaileyJM02

@cr2007 here is a short suggestions to fixe the issue:

      - name: Convert Docs Markdown to PDF
        uses: baileyjm02/markdown-to-pdf@v1
        with:
          input_path: Journals
          output_dir: pdf
          build_html: false
          images_dir: Journals/images
          image_import: images

and now important, in your markdown file you should try this:

![Image Text](images/myimage.png)

where the path for the image itself is: Journals/images/myimage.png and path to markdown is: Journals/mymarkdown.md

Sp0ngy avatar Nov 29 '23 16:11 Sp0ngy

So you mean like state the Absolute path, instead of the relative path?

Would that be the fix to the issue?

cr2007 avatar Nov 30 '23 16:11 cr2007

@cr2007 I didn't look at the sourcecode so I wouldn't suggest it as a fix. But try it out and check if it works.

Sp0ngy avatar Nov 30 '23 17:11 Sp0ngy

@cr2007 here is a short suggestions to fixe the issue:

      - name: Convert Docs Markdown to PDF
        uses: baileyjm02/markdown-to-pdf@v1
        with:
          input_path: Journals
          output_dir: pdf
          build_html: false
          images_dir: Journals/images
          image_import: images

and now important, in your markdown file you should try this:

![Image Text](images/myimage.png)

where the path for the image itself is: Journals/images/myimage.png and path to markdown is: Journals/mymarkdown.md

Tried this to long back in here, didn't exactly work out as planned

I'm happy to give you access to the repository if it helps in resolving the issue

cr2007 avatar Dec 01 '23 03:12 cr2007