jxxcarlson

jxxcarlson

Display PDF file

I am trying to display a PDF file that I have on disk using this:

<div>
  <h4>PDF File:</h4>
   <%= @data %>
</div>

However, the page looks like gibberish. Same if I use <%= Phoenix.HTML.raw @data %>

Marked As Solved

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

To render it in the middle of the page you’ll need to leverage some javascript https://stackoverflow.com/questions/291813/recommended-way-to-embed-pdf-in-html

Also Liked

NobbZ

NobbZ

in your controller set the appropriate content type and then stream the payload into the conn.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@jxxcarlson are you trying to send them a pdf file? or render it inline with html? If you’re just sending them a file then use Plug.Conn — Plug v1.20.2

Last Post!

jxxcarlson

jxxcarlson

@benwilson512

Your send file solution works great! Thanks!!

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement