Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements #20

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,26 @@ on:

jobs:
build:
if: |
!startsWith(github.event.head_commit.message, '[Skip CI]')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: make install
- run: make gh-pages/tarball
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: artifacts.tar.bz2
path: artifacts.tar.bz2
runs-on: ubuntu-latest
lint:
if: |
!startsWith(github.event.head_commit.message, '[Skip CI]')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: |
Expand All @@ -49,11 +45,9 @@ jobs:
- build
- lint
if: |
github.ref == 'refs/heads/master' &&
github.event_name != 'pull_request' &&
!startsWith(github.event.head_commit.message, '[Skip Deploy]')
github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: artifacts.tar.bz2
- run: tar --extract --bzip2 --verbose --file=artifacts.tar.bz2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
beautifulsoup4==4.12.0
lxml==4.9.4
PyPDF2==2.12.1
pypdf==3.17.4
PyYAML==6.0.1
reportlab==3.6.13
2 changes: 1 addition & 1 deletion scripts/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (!argv.source || !argv.output) {
}

// generate pdf
puppeteer.launch({ args: [ '--no-sandbox' ] }).then(async browser => {
puppeteer.launch({ args: [ '--no-sandbox' ], headless: "new" }).then(async browser => {

const page = await browser.newPage();
const response = await page.goto(argv.source);
Expand Down
18 changes: 9 additions & 9 deletions scripts/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from os import P_WAIT, path, remove, spawnlp
from os.path import basename
from PyPDF2 import PdfFileReader, PdfFileWriter
from pypdf import PdfReader, PdfWriter
from tempfile import NamedTemporaryFile
from argparse import ArgumentParser
from reportlab.pdfbase import pdfmetrics
Expand All @@ -27,7 +27,7 @@
args = parser.parse_args()

# denouement
output = PdfFileWriter()
output = PdfWriter()

# intermediate docs
intermediate = NamedTemporaryFile(mode='wb')
Expand All @@ -39,8 +39,8 @@
# construct denouement
with open(intermediate.name, 'rb') as resume, open(forefront.name, 'rb') as forepart:

intermediate.pdf = PdfFileReader(resume)
forefront.pages = intermediate.pdf.getNumPages()
intermediate.pdf = PdfReader(resume)
forefront.pages = len(intermediate.pdf.pages)

forefront.canvas = Canvas(filename=forefront.name, pagesize=A4, initialFontName='Helvetica')

Expand All @@ -62,24 +62,24 @@
forefront.canvas.save()

# read constructed custom headers
forefront.pdf = PdfFileReader(forepart)
forefront.pdf = PdfReader(forepart)

# merge resume and headers
for i in range(0, forefront.pages):
intermediate.pdf.getPage(i).mergePage(forefront.pdf.getPage(i))
output.addPage(intermediate.pdf.getPage(i))
intermediate.pdf.pages[i].merge_page(forefront.pdf.pages[i])
output.add_page(intermediate.pdf.pages[i])

# add metadata
# https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdfmark_reference.pdf
output.addMetadata({
output.add_metadata({
'/Subject': 'Curriculum Vitae',
'/Creator': 'XMLResume (https://github.com/ashenm/xmlresume)',
'/Title': 'Curriculum Vitae - Ashen Gunaratne',
'/Author': 'Ashen Gunaratne'
})

# configure initial view
output.setPageLayout('/SinglePage')
output.page_layout = '/SinglePage'

# write output
with open('resume.pdf', 'wb') as file:
Expand Down