2

I am converting markdown documents to PDF with Pandoc using PowerShell and want to turn off the image rendering. Is there a way to do this without touching the Markdown itself?

The Markdown documents are mainly for use on SharePoint, but I do also want to be able to convert them to DOCX and PDF.

The images in the Markdown therefore link to locations on SharePoint, so Pandoc cannot access them. The images themselves aren't important in the converted documents, since it is the rest of the content that needs to reviewed/archived.

When I run my DOCX conversion, all documents convert well enough, and where there are images, the 'missing image' box appears. This is fine.

When I run my PDF conversion in PowerShell:

gci -r -i *.md | foreach{$pdf=$_.directoryname+"\"+$_.basename+".pdf"
; pandoc --pdf-engine=xelatex -f markdown -s $_.name -o $pdf}
; mkdir .\pdf
; gci -r -i *.pdf | foreach{$pdf=$_.directoryname+"\"+$_.basename+".pdf"
; move-item $pdf .\pdf\}

Actual Result: This prevents the entire PDF for this file from being converted. PDFs without these images convert nicely.

For each Image I get the error:

Could not convert image

'C:/Users/xxx/AppData/Local/Temp/tex2pdf.-yyy/zzz.vs': Cannot load file

Jpeg not enough bytes

PNG, Bitmap, Gif, HDR, Tiff, TGA not enough bytes

Error producing PDF.

! LaTeX Error: Cannot determine size of graphic in C://Users/xxx/AppData/Loc al/Temp/tex2pdf.-yyy/zzz.vs (no BoundingBox).

The Error says I should 'Try running pandoc with --pdf-engine=xelatex.'. I get the same result (I have included how I used this addition in the example above)

Ideally, the output in the PDF would show where the image would be if it were there, or that line would simply not be displayed.

I was thinking if there were some code I could put around the image links that doesn't display in SharePoint, but does stop any errors in Pandoc, that could be ideal; or, if there was a way to shut down all image rendering in the PowerShell script, that might also be an idea.

Many thanks in advance for any ideas you may have!

Community
  • 1
  • 1
JV53
  • 69
  • 6
  • 1
    Check out this question: https://stackoverflow.com/q/57393261/2425163; you might be able to use the same technique to get rid of the images. – tarleb Aug 09 '19 at 09:26
  • 1
    This worked perfectly, I modified the lua so that the tables still showed, but the images were all removed. Thank you very kindly! – JV53 Aug 09 '19 at 11:48
  • Most welcome, glad it worked :) – tarleb Aug 09 '19 at 11:58
  • 1
    Possible duplicate of [How can I strip figures and table during a pandoc LaTeX to Word conversion?](https://stackoverflow.com/questions/57393261/how-can-i-strip-figures-and-table-during-a-pandoc-latex-to-word-conversion) – tarleb Aug 10 '19 at 15:05

0 Answers0