An open API service indexing awesome lists of open source software.

https://github.com/xtenzq/latex-pdfjs-viewer

Build LaTeX into PDF and deploy it to GitHub Pages + PDF.js
https://github.com/xtenzq/latex-pdfjs-viewer

cv-latex github-actions github-actions-latex latex-to-gh-pages latex-to-github-pages latex-to-pdf pdfjs

Last synced: about 1 month ago
JSON representation

Build LaTeX into PDF and deploy it to GitHub Pages + PDF.js

Awesome Lists containing this project

README

          

# LaTeX-to-PDF with GitHub Pages + PDF.js

[![CI](https://github.com/xtenzQ/latex-pdfjs-viewer/actions/workflows/blank.yml/badge.svg)](https://github.com/xtenzQ/latex-pdfjs-viewer/actions/workflows/blank.yml) [![pages-build-deployment](https://github.com/xtenzQ/latex-pdfjs-viewer/actions/workflows/pages/pages-build-deployment/badge.svg?branch=gh-pages)](https://github.com/xtenzQ/latex-pdfjs-viewer/actions/workflows/pages/pages-build-deployment)

Builds LaTeX doc into PDF and then publishes it on GitHub Pages so we can now embed our PDF with the following link:
```
https://.github.io//
```
**[Example](https://rusetskii.dev/latex-pdfjs-viewer/)**

## Structure

- `pdfjs` - contains PDF.js viewer built from sources
- `doc.tex` - the LaTeX document to be published

## Deployment

Using GitHub Actions, LaTeX document is converted into PDF and deployed to GitHub Pages together with PDF.js viewer.

## Building from scratch

Want to build your own converter with viewer?
1. Clone PDF.JS
```
$ git clone https://github.com/mozilla/pdf.js.git
$ cd pdf.js
```
2. Install dependencies
```
$ npm install
```
3. Build from sources
```
$ gulp generic
```
4. Copy built sources to your repo's `pdfjs` folder
```
$ cp -r build/generic /pdfjs
```
5. Create `index.html` in your repo on the path `/pdfjs`
```HTML








```
6. Put your LaTeX file in the root of your repo and rename it to `doc.tex`.
7. Create GitHub Actions workflow `build.yml` on the path `.github\workflows`:
```YML
name: LaTeX-to-PDF

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- 'doc.tex'
- 'pdfjs/**'
- '.github/workflows/blank.yml'
pull_request:
branches: [ main ]
paths:
- 'doc.tex'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2

- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: doc.tex

- name: Copy file
run: |
sudo mv doc.pdf pdfjs

- name: Deploy to gh-pages
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: gh-pages
FOLDER: pdfjs
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MESSAGE: "deploy website"
```
8. Set your GitHub Pages in Settings to the branch `gh-pages`.