BaileyJM02 / markdown-to-pdf

A GitHub Action to make PDF and HTML files from Markdown
MIT License
131 stars 32 forks source link

Image not rendering in the PDF #53

Open cr2007 opened 1 year ago

cr2007 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@BaileyJM02 Is there any update on this?

cr2007 commented 1 year ago

@BaileyJM02

BaileyJM02 commented 1 year ago

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

cr2007 commented 1 year ago

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 commented 1 year ago

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

BaileyJM02 commented 1 year ago

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

cr2007 commented 1 year ago

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 commented 1 year ago

Hey @BaileyJM02

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

cr2007 commented 1 year ago

@BaileyJM02

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

BaileyJM02 commented 1 year ago

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

cr2007 commented 1 year ago

Hey @BaileyJM02

Any update on this issue and #54 ?

cr2007 commented 12 months ago

@BaileyJM02

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

BaileyJM02 commented 12 months ago

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?

cr2007 commented 12 months ago

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

BaileyJM02 commented 12 months ago

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.

Sp0ngy commented 11 months ago

@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

cr2007 commented 11 months ago

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

Would that be the fix to the issue?

Sp0ngy commented 11 months ago

@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.

cr2007 commented 11 months ago

@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