UNPKG

pdfix-sdk

Version:

Take the full control over the PDF documents with PDFix SDK. Leverage the advantages of the PDFix SDK WebAssembly build for use in both Node.js and web applications

36 lines (28 loc) 915 B
const Pdfix = require('./index'); describe('Pdfix', () => { let pdfix; beforeAll(async () => { pdfix = new Pdfix(); await pdfix.loadPdfixSdk(); }); afterAll(() => { pdfix.getPdfixSdk().GetPdfix().Destroy(); }); it('should create Pdfix instance', () => { expect(pdfix).toBeInstanceOf(Pdfix); }); it('should open a document from path', () => { const pdfDoc = pdfix.openDocumentFromPath('./pdf/test.pdf'); expect(pdfDoc).toBeDefined(); }); it('should open a document from URL', async () => { const pdfDoc = await pdfix.openDocumentFromUrl('https://pdfix.net/pdf/test.pdf'); expect(pdfDoc).toBeDefined(); }); it('should render a page to an image', () => { const pdfDoc = pdfix.openDocumentFromPath('./pdf/test.pdf'); const pageNumber = 0; const imageBlob = pdfix.renderPage(pdfDoc, pageNumber); expect(imageBlob).toBeDefined(); }); });