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

test: add tests for issue #42 #58

Closed
wants to merge 1 commit into from
Closed
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
Binary file added test/fixtures/issue-42.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions test/issues.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const pdf = require('pdfjs')
const fs = require('fs-extra')

const PDFMerger = require('../index')
Expand All @@ -25,6 +26,27 @@ describe('issues', () => {
await merger.save(path.join(TMP_DIR, 'Testfile_BA.pdf'))
})

test.skip('merge compressed pdfs (#42)', async () => {
// can pdfjs handle this file?
const doc = new pdf.Document()
const src = await fs.readFile(path.join(FIXTURES_DIR, 'issue-42.pdf'))
const ext = new pdf.ExternalDocument(src)
doc.addPagesOf(ext)
const fileBuffer = await doc.asBuffer()
await fs.writeFile(path.join(TMP_DIR, 'Testfile_issue-42_1.pdf'), fileBuffer)

// ok let's try to use pdf-merger-js
const merger = new PDFMerger()
merger.add(path.join(FIXTURES_DIR, 'issue-42.pdf'))

// first let's make sure we can save the file
await merger.save(path.join(TMP_DIR, 'Testfile_issue-42_2.pdf'))

// can we also save the file as a buffer?
const buffer = await merger.saveAsBuffer()
await fs.writeFile(path.join(TMP_DIR, 'Testfile_issue-42_3.pdf'), buffer)
})

afterAll(async () => {
await fs.remove(TMP_DIR)
})
Expand Down