Is it possible to manually set the content-type to make a pdf

So, originally I was using a GH Action to download a pdf export from the Google Drive apis (was going to link to the post for content, but I think my site is flagged cause I posted about a project fixing what I thought was an issue, and it was considered spammy?).

But anyway, I realized that since I’m doing a load_data for the html version, which is nice for local testing, why not try to see if I can do it for the pdf. The docs have an svg after all.

From poking at the docs and code, I suspect the answer is “no, only these specific text content-types work” (but I missed aliases and made my own redirects, so maybe I missed something here too). I can get the data, but it’s still being wrapped in an <html>etc and I haven’t looked at the headers yet, but I feel like they are not gonna tell me anything I like.

Is it possible?

Repo for context: wow, I’m disallowed from posting even github for a question. Harsh.

+++
title = "test"
template = "test.md"
path="resume.pdf"
content-type="application/pdf"
draft=true
[extra]
file_id = "1kIqp7dlp3ve_OZwADFs-07_ufVsyChBLz_1YKgn8ElU"
+++

template:

{%-set url = "https://www.googleapis.com/drive/v2/files/" ~ page.extra.file_id ~  "/export?mimeType=application/pdf&key=" ~ get_env(name="GAPI_KEY")-%}{{- load_data(url=url) | safe -}}

No you can’t, zola is only outputting HTML (or in some cases XML for feeds)

1 Like

Thought not, Thanks!

… And images (image_resize does write non text based files). :wink:

It’s less "ouput pdf’ specifically than “prefetch remote assets” but I can’t figure out any other way to get it to output a file from the load_data than running it through a template.

Well I guess I’m excited to see what you come up with for scripting or extensions so I can make a “fetch_asset” step or a “write_to_file” filter for load_data or something. :slight_smile:

Time to figure a simple wrapper that runs a GH action through act before a zola serve maybe? Maybe extract the wget, test, move to a “fetch assets” shell script (that the GH deploy actions calls to avoid repetition) that I can call locally && with zola serve? Yeah that sounds cleaner (edit: and it was pretty easy to extract and call).