Giter VIP home page Giter VIP logo

latex-pdfjs-viewer's Introduction

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

CI 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://<username>.github.io/<repo>/

Example

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
  1. Install dependencies
$ npm install
  1. Build from sources
$ gulp generic
  1. Copy built sources to your repo's pdfjs folder
$ cp -r build/generic <your repo>/pdfjs
  1. Create index.html in your repo on the path <your repo>/pdfjs
<!DOCTYPE html>
<html dir="ltr" mozdisallowselectionprint>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="google" content="notranslate">
  </head>
  <body style="height: 100%; width: 100%; overflow: hidden; margin:0px; background-color: rgb(82, 86, 89);">
    <iframe src="web/viewer.html" title="CV" frameBorder="0" style="position:absolute; left: 0; top: 0;" width="100%" height="100%">
  </body>
</html>
  1. Put your LaTeX file in the root of your repo and rename it to doc.tex.
  2. Create GitHub Actions workflow build.yml on the path .github\workflows:
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"
  1. Set your GitHub Pages in Settings to the branch gh-pages.

latex-pdfjs-viewer's People

Contributors

xtenzq avatar poseidon-archt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.