### Install DocDock from ZIP Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md Install the theme by downloading and extracting a ZIP archive. The theme files will be tracked within the parent repository. ```bash https://github.com/vjeantet/hugo-theme-docdock/archive/master.zip ``` -------------------------------- ### Asynchronous PDF Open Example Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Example demonstrating how to open a PDF in a new window asynchronously, typically after fetching data. ```javascript $scope.generatePdf = function() { // create the window before the callback var win = window.open('', '_blank'); $http.post('/someUrl', data).then(function(response) { // pass the "win" argument pdfMake.createPdf(docDefinition).open(win); }); }; ``` -------------------------------- ### Install Multiplex Plugin Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Install the necessary dependencies for the Multiplex plugin. This is a prerequisite for running the Socket.io server. ```bash npm install ``` ```bash node plugin/multiplex ``` -------------------------------- ### Install DocDock as Git Clone Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md An alternative method to install the theme by cloning the repository directly. Files are checked out locally but not visible from the parent git repo. ```bash $ git clone https://github.com/vjeantet/hugo-theme-docdock.git themes/docdock ``` -------------------------------- ### Copy Sample Configuration Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md Copy the sample configuration file from the theme's example site to your Hugo root directory. ```bash $ cp themes/docdock/exampleSite/config.toml . ``` -------------------------------- ### Complete Server-side PDF Generation Example Source: https://context7.com/pdfmake/docs/llms.txt This example demonstrates a full server-side PDF generation workflow using pdfmake, including font definitions, access policy, document structure, and PDF creation with file writing. ```javascript const pdfmake = require('pdfmake'); pdfmake.addFonts({ Roboto: { normal: 'fonts/Roboto-Regular.ttf', bold: 'fonts/Roboto-Medium.ttf', italics: 'fonts/Roboto-Italic.ttf', bolditalics: 'fonts/Roboto-MediumItalic.ttf' } }); pdfmake.setLocalAccessPolicy(path => path.startsWith('fonts/')); const docDefinition = { info: { title: 'Invoice #1042', author: 'Acme Corp' }, pageSize: 'A4', pageMargins: [40, 60, 40, 60], header: { text: 'Acme Corp — Invoice', alignment: 'right', margin: [0, 10, 40, 0] }, footer: (page, total) => ({ text: `${page} / ${total}`, alignment: 'center' }), watermark: { text: 'DRAFT', opacity: 0.08, angle: -45 }, content: [ { text: 'Invoice #1042', style: 'title' }, { layout: 'lightHorizontalLines', table: { headerRows: 1, widths: ['*', 'auto', 80, 80], body: [ [{ text: 'Description', bold: true }, { text: 'Qty', bold: true }, { text: 'Unit Price', bold: true }, { text: 'Total', bold: true }], ['Web development services', '40 h', '$150', '$6,000'], ['Hosting (annual)', '1', '$240', '$240'], [{ text: 'Grand Total', bold: true, colSpan: 3 }, '', '', { text: '$6,240', bold: true }] ] } } ], styles: { title: { fontSize: 22, bold: true, marginBottom: 16 } }, defaultStyle: { font: 'Roboto', fontSize: 11, lineHeight: 1.4 } }; pdfmake.createPdf(docDefinition) .write('invoice-1042.pdf') .then(() => console.log('invoice-1042.pdf created')) .catch(err => console.error('PDF generation failed:', err)); ``` -------------------------------- ### Clone and Start pdfmake Docs Website Source: https://github.com/pdfmake/docs/blob/master/README.md Clone the documentation repository and start the Hugo development server to view the website locally. Open http://localhost:1313/docs/0.3/ in your browser. ```bash git clone --branch master https://github.com/pdfmake/docs.git cd docs hugo server ``` ```bash http://localhost:1313/docs/0.3/ ``` -------------------------------- ### Install Reveal.js Dependencies Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Install the necessary Node.js dependencies for reveal.js development. ```sh $ npm install ``` -------------------------------- ### Reveal.js Initialization with Configuration Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/test/examples/slide-backgrounds.html Initialize Reveal.js with various configuration options. This example shows 'center', 'rtl', 'transition', and 'backgroundTransition'. ```javascript Reveal.initialize({ center: true, // rtl: true, transition: 'linear', // transitionSpeed: 'slow', // backgroundTransition: 'slide' }); ``` -------------------------------- ### Setup Notes UI Elements Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes-server/notes.html Initializes references to the DOM elements used for displaying speaker notes. ```javascript /* * Setup the notes UI. */ function setupNotes() { notes = document.querySelector( '.speaker-controls-notes' ); notesValue = document.querySelector( '.speaker-controls-notes .value' ); } ``` -------------------------------- ### Asynchronous PDF Print Example Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Example demonstrating how to print a PDF asynchronously, typically after fetching data. ```javascript $scope.generatePdf = function() { // create the window before the callback var win = window.open('', '_blank'); $http.post('/someUrl', data).then(function(response) { // pass the "win" argument pdfMake.createPdf(docDefinition).print(win); }); }; ``` -------------------------------- ### Install DocDock as Git Submodule Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md Recommended method for installing the DocDock theme. This adds the theme as a dependency repository, which is necessary for CI tools like Netlify or Jenkins. ```bash $ git submodule add https://github.com/vjeantet/hugo-theme-docdock.git themes/docdock ``` -------------------------------- ### Install pdfmake via npm Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/server-side/_index.md Install the pdfmake package using npm for server-side projects. ```bash npm install pdfmake ``` -------------------------------- ### Basic Server-side PDF Generation Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/server-side/_index.md Example demonstrating how to define fonts, require the library, set up a document definition, and create a PDF file on the server. ```javascript // Define font files var fonts = { Roboto: { normal: 'fonts/Roboto-Regular.ttf', bold: 'fonts/Roboto-Medium.ttf', italics: 'fonts/Roboto-Italic.ttf', bolditalics: 'fonts/Roboto-MediumItalic.ttf' } }; var pdfmake = require('pdfmake'); pdfmake.addFonts(fonts); var docDefinition = { // ... }; var options = { // ... } var pdf = pdfmake.createPdf(docDefinition); pdf.write('document.pdf').then(() => { // success event }, err => { // error event console.error(err); }); ``` -------------------------------- ### Setup Speaker Timer and Clock Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes/notes.html Initializes and updates the speaker timer and clock. It calculates time differences and displays them, also handling pacing information if timings are provided. Call this function to start the timer. ```javascript function setupTimer() { var start = new Date(), timeEl = document.querySelector( '.speaker-controls-time' ), clockEl = timeEl.querySelector( '.clock-value' ), hoursEl = timeEl.querySelector( '.hours-value' ), minutesEl = timeEl.querySelector( '.minutes-value' ), secondsEl = timeEl.querySelector( '.seconds-value' ), pacingTitleEl = timeEl.querySelector( '.pacing-title' ), pacingEl = timeEl.querySelector( '.pacing' ), pacingHoursEl = pacingEl.querySelector( '.hours-value' ), pacingMinutesEl = pacingEl.querySelector( '.minutes-value' ), pacingSecondsEl = pacingEl.querySelector( '.seconds-value' ); var timings = getTimings(); if (timings !== null) { pacingTitleEl.style.removeProperty('display'); pacingEl.style.removeProperty('display'); } function _displayTime( hrEl, minEl, secEl, time) { var sign = Math.sign(time) == -1 ? "-" : ""; time = Math.abs(Math.round(time / 1000)); var seconds = time % 60; var minutes = Math.floor( time / 60 ) % 60 ; var hours = Math.floor( time / ( 60 * 60 )) ; hrEl.innerHTML = sign + zeroPadInteger( hours ); if (hours == 0) { hrEl.classList.add( 'mute' ); } else { hrEl.classList.remove( 'mute' ); } minEl.innerHTML = ':' + zeroPadInteger( minutes ); if (hours == 0 && minutes == 0) { minEl.classList.add( 'mute' ); } else { minEl.classList.remove( 'mute' ); } secEl.innerHTML = ':' + zeroPadInteger( seconds ); } function _updateTimer() { var diff, hours, minutes, seconds, now = new Date(); diff = now.getTime() - start.getTime(); clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } ); _displayTime( hoursEl, minutesEl, secondsEl, diff ); if (timings !== null) { _updatePacing(diff); } } function _updatePacing(diff) { var slideEndTiming = getTimeAllocated(timings) * 1000; var currentSlide = Reveal.getSlidePastCount(); var currentSlideTiming = timings[currentSlide] * 1000; var timeLeftCurrentSlide = slideEndTiming - diff; if (timeLeftCurrentSlide < 0) { pacingEl.className = 'pacing behind'; } else if (timeLeftCurrentSlide < currentSlideTiming) { pacingEl.className = 'pacing on-track'; } else { pacingEl.className = 'pacing ahead'; } _displayTime( pacingHoursEl, pacingMinutesEl, pacingSecondsEl, timeLeftCurrentSlide ); } // Update once directly _updateTimer(); // Then update every second setInterval( _updateTimer, 1000 ); function _resetTimer() { if (timings == null) { start = new Date(); } else { // Reset timer to beginning of current slide var slideEndTiming = getTimeAllocated(timings) * 1000; var currentSlide = Reveal.getSlidePastCount(); var currentSlideTiming = timings[currentSlide] * 1000; var previousSlidesTiming = slideEndTiming - currentSlideTiming; var now = new Date(); start = new Date(now.getTime() - previousSlidesTiming); } _updateTimer(); } timeEl.addEventListener( 'click', function() { _resetTimer(); return false; } ); } ``` -------------------------------- ### Install and Use pdfmake in Node.js Source: https://context7.com/pdfmake/docs/llms.txt Install pdfmake using npm. This snippet shows how to require the library, define custom fonts, and create a PDF file on disk. ```js // npm install pdfmake const pdfmake = require('pdfmake'); const fonts = { Roboto: { normal: 'fonts/Roboto-Regular.ttf', bold: 'fonts/Roboto-Medium.ttf', italics: 'fonts/Roboto-Italic.ttf', bolditalics: 'fonts/Roboto-MediumItalic.ttf' } }; pdmake.addFonts(fonts); const docDefinition = { content: 'Hello from Node.js!' }; pdmake.createPdf(docDefinition) .write('output.pdf') .then(() => console.log('Done')) .catch(err => console.error(err)); ``` -------------------------------- ### Setup Speaker Layouts in Reveal.js Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes-server/notes.html Initializes the speaker layout dropdown and event listener. Renders available layouts from SPEAKER_LAYOUTS and restores the previously selected layout. ```javascript function setupLayout() { layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); layoutLabel = document.querySelector( '.speaker-layout-label' ); // Render the list of available layouts for( var id in SPEAKER_LAYOUTS ) { var option = document.createElement( 'option' ); option.setAttribute( 'value', id ); option.textContent = SPEAKER_LAYOUTS[ id ]; layoutDropdown.appendChild( option ); } // Monitor the dropdown for changes layoutDropdown.addEventListener( 'change', function( event ) { setLayout( layoutDropdown.value ); }, false ); // Restore any currently persisted layout setLayout( getLayout() ); } ``` -------------------------------- ### Serve Reveal.js Presentation Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Start a local web server to serve the presentation and monitor source files for changes. The default port is 8000, but can be changed using the --port flag. ```sh $ npm start ``` ```sh $ npm start -- --port=8001 ``` -------------------------------- ### Install and Use pdfmake in Browser Source: https://context7.com/pdfmake/docs/llms.txt Include pdfmake via CDN or npm. This snippet demonstrates basic browser usage by creating and downloading a PDF. ```html ``` -------------------------------- ### Initialize Notes Server and WebSocket Connection Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes-server/notes.html Sets up the WebSocket connection to the server and initializes variables for managing slide states and UI elements. It also handles initial setup for layouts, iframes, and event listeners. ```javascript (function() { var notes, notesValue, currentState, currentSlide, upcomingSlide, layoutLabel, layoutDropdown, connected = false; var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; var SPEAKER_LAYOUTS = { 'default': 'Default', 'wide': 'Wide', 'tall': 'Tall', 'notes-only': 'Notes only' }; socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours if( data.socketId !== socketId ) { return; } if( connected === false ) { connected = true; setupKeyboard(); setupNotes(); setupTimer(); } handleStateMessage( data ); } ); setupLayout(); // Load our presentation iframes setupIframes(); // Once the iframes have loaded, emit a signal saying there's // a new subscriber which will trigger a 'statechanged' // message to be sent back window.addEventListener( 'message', function( event ) { var data = JSON.parse( event.data ); if( data && data.namespace === 'reveal' ) { if( /ready/.test( data.eventName ) ) { socket.emit( 'new-subscriber', { socketId: socketId } ); } } // Messages sent by reveal.js inside of the current slide preview if( data && data.namespace === 'reveal' ) { if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { socket.emit( 'statechanged-speaker', { state: data.state } ); } } } ); ``` -------------------------------- ### Clone Reveal.js Repository Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Clone the reveal.js repository to your local machine to begin development or use the full setup. ```sh $ git clone https://github.com/hakimel/reveal.js.git ``` -------------------------------- ### Building pdfmake with Standard Fonts Source: https://github.com/pdfmake/docs/blob/master/content/fonts/standard-14-fonts.md Instructions for cloning the pdfmake repository, installing dependencies, and building the library with standard fonts included. This is necessary for client-side usage of standard fonts. ```bash git clone https://github.com/bpampuch/pdfmake.git cd pdfmake npm install gulp buildWithStandardFonts ``` -------------------------------- ### Composer.json for pdfmake asset Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/_index.md Example composer.json configuration to include pdfmake as an npm asset for PHP projects. ```json { "require": { "npm-asset/pdfmake": "^0.3.0" }, "replace": { "npm-asset/pdfkit": "*", "npm-asset/linebreak": "*", "npm-asset/svg-to-pdfkit": "*", "npm-asset/xmldoc": "*" }, "repositories": [ { "type": "composer", "url": "https://asset-packagist.org" } ] } ``` -------------------------------- ### Preview Hugo Site Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md Start the Hugo development server to preview your site locally. The site will be available at http://localhost:1313. ```bash $ hugo server ``` -------------------------------- ### Initialize and Update Timer/Clock Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes-server/notes.html Sets up a timer and clock display that starts from a defined point and updates every second. The timer can be reset by clicking on the time element. ```javascript /* * Create the timer and clock and start updating them * at an interval. */ function setupTimer() { var start = new Date(), timeEl = document.querySelector( '.speaker-controls-time' ), clockEl = timeEl.querySelector( '.clock-value' ), hoursEl = timeEl.querySelector( '.hours-value' ), minutesEl = timeEl.querySelector( '.minutes-value' ), secondsEl = timeEl.querySelector( '.seconds-value' ); function _updateTimer() { var diff, hours, minutes, seconds, now = new Date(); diff = now.getTime() - start.getTime(); hours = Math.floor( diff / ( 1000 * 60 * 60 ) ); minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 ); seconds = Math.floor( ( diff / 1000 ) % 60 ); clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } ); hoursEl.innerHTML = zeroPadInteger( hours ); hoursEl.className = hours > 0 ? '' : 'mute'; minutesEl.innerHTML = ':' + zeroPadInteger( minutes ); minutesEl.className = minutes > 0 ? '' : 'mute'; secondsEl.innerHTML = ':' + zeroPadInteger( seconds ); } // Update once directly _updateTimer(); // Then update every second setInterval( _updateTimer, 1000 ); timeEl.addEventListener( 'click', function() { start = new Date(); _updateTimer(); return false; } ); } ``` -------------------------------- ### Reveal.js Fragment Styling Examples Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Shows how to apply different visual effects to fragments on a slide using CSS classes. Fragments control element visibility and transitions between steps. ```html

grow

shrink

fade-out

fade-up (also down, left and right!)

visible only once

blue only once

highlight-red

highlight-green

highlight-blue

``` -------------------------------- ### Setup Speaker View Layout Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes/notes.html Configures the speaker view layout by populating a dropdown with available layouts and setting up an event listener for layout changes. It also restores the last used layout. ```javascript function setupLayout() { layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); layoutLabel = document.querySelector( '.speaker-layout-label' ); // Render the list of available layouts for( var id in SPEAKER_LAYOUTS ) { var option = document.createElement( 'option' ); option.setAttribute( 'value', id ); option.textContent = SPEAKER_LAYOUTS[ id ]; layoutDropdown.appendChild( option ); } // Monitor the dropdown for changes layoutDropdown.addEventListener( 'change', function( event ) { setLayout( layoutDropdown.value ); }, false ); // Restore any currently persisted layout setLayout( getLayout() ); } ``` -------------------------------- ### Reveal.js Client Configuration with Multiplex Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Configure Reveal.js to connect as a client to a Socket.io server. This setup synchronizes the client presentation with a master presentation. Ensure the `secret` is null for clients. ```javascript Reveal.initialize({ // other options... multiplex: { // Example values. To generate your own, see the socket.io server instructions. secret: null, // null so the clients do not have control of the master presentation id: '1ea875674b17ca76', // id, obtained from socket.io server url: 'example.com:80' // Location of your socket.io server }, // Don't forget to add the dependencies dependencies: [ { src: '//cdn.socket.io/socket.io-1.3.5.js', async: true }, { src: 'plugin/multiplex/client.js', async: true } // other dependencies... ] }); ``` -------------------------------- ### Setup Keyboard Event Forwarding Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/notes-server/notes.html Forwards keyboard events to the current slide's iframe, allowing control of the presentation even when the iframe does not have focus. ```javascript /* * Forward keyboard events to the current slide window. * This enables keyboard events to work even if focus * isn't set on the current slide iframe. */ function setupKeyboard() { document.addEventListener( 'keydown', function( event ) { currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*'); } ); } ``` -------------------------------- ### Set URL Access Policy - Basic Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/server-side/methods.md The `setUrlAccessPolicy` method defines a custom security policy for external URLs. This basic example restricts access to URLs starting with a specific domain. ```javascript pdfmake.setUrlAccessPolicy((url) => { // check allowed domain return url.startsWith("https://example.com/"); }); ``` -------------------------------- ### Configure Slide Number Display Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md JavaScript examples for configuring the slide number display in Reveal.js. Options include formatting ('c/t') and controlling visibility ('speaker', 'print'). ```javascript // Shows the slide number using default formatting Reveal.configure({ slideNumber: true }); // Slide number formatting can be configured using these variables: // "h.v": horizontal . vertical slide number (default) // "h/v": horizontal / vertical slide number // "c": flattened slide number // "c/t": flattened slide number / total slides Reveal.configure({ slideNumber: 'c/t' }); // Control which views the slide number displays on using the "showSlideNumber" value: // "all": show on all views (default) // "speaker": only show slide numbers on speaker notes view // "print": only show slide numbers when printing to PDF Reveal.configure({ showSlideNumber: 'speaker' }); ``` -------------------------------- ### Render Probability Formula with Reveal.js Math Plugin Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/test/examples/math.html Displays the probability of getting k heads when flipping n coins using LaTeX within Reveal.js. MathJax and the Reveal.js Math plugin must be configured. ```html \\[P(E) = {n \\choose k} p^k (1-p)^{ n-k} \\\] ``` -------------------------------- ### Configure Reveal.js Master Presentation for Multiplex Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Configuration for the master presentation when using the multiplex plugin. This setup requires a secret, an ID, and the URL of the socket.io server. Ensure the necessary dependencies are included. ```javascript Reveal.initialize({ // other options... multiplex: { // Example values. To generate your own, see the socket.io server instructions. secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation id: '1ea875674b17ca76', // Obtained from socket.io server url: 'https://reveal-js-multiplex-ccjbegmaii.now.sh' // Location of socket.io server }, // Don't forget to add the dependencies dependencies: [ { src: '//cdn.socket.io/socket.io-1.3.5.js', async: true }, { src: 'plugin/multiplex/master.js', async: true }, // and if you want speaker notes { src: 'plugin/notes-server/client.js', async: true } // other dependencies... ] }); ``` -------------------------------- ### Define Document Section with Inherited Properties Source: https://github.com/pdfmake/docs/blob/master/content/document-definition-object/sections.md This example shows how to define a section where properties like header, footer, background, watermark, page size, orientation, and margins are inherited from the preceding section. Only the content specific to this section needs to be provided. ```javascript var docDefinition = { content: [ { header: 'inherit', footer: 'inherit', background: 'inherit', watermark: 'inherit', pageSize: 'inherit', pageOrientation: 'inherit', pageMargins: 'inherit', section: [ 'Text in section.' ] } ] } ``` -------------------------------- ### Initialize Hugo Site Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md Use this command to create a new, empty Hugo site with the minimal required directory structure. ```bash $ hugo new site . ``` -------------------------------- ### Get PDF as ArrayBuffer using getBuffer() Source: https://context7.com/pdfmake/docs/llms.txt Use `getBuffer()` to get the PDF content as an ArrayBuffer. This is suitable for binary data processing or sending to Node.js environments. ```javascript pdfMake.createPdf(docDefinition).getBuffer().then(buffer => { console.log('Buffer size:', buffer.byteLength); }, err => console.error(err)); ``` -------------------------------- ### Reveal.js Initialization with Math Plugin Configuration Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/test/examples/math.html Shows how to initialize Reveal.js with the Math plugin enabled, including configuration options for MathJax. ```javascript Reveal.initialize({ history: true, transition: 'linear', math: { // mathjax: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js', config: 'TeX-AMS\_HTML-full' }, dependencies: [ { src: '../../lib/js/classList.js' }, { src: '../../plugin/math/math.js', async: true } ] }); ``` -------------------------------- ### Get PDF as Stream Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieves the PDF document as a stream. ```APIDOC ## Get PDF as Stream ### Description Retrieves the PDF document as a stream. ### Method Signature ```javascript pdfMake.createPdf(docDefinition).getStream() ``` ### Response #### Success Response - **stream** (Stream) - The PDF document as a stream. ``` -------------------------------- ### Initialize Reveal.js with Dependencies Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Configure Reveal.js by specifying an array of dependencies to load. Each dependency object can include a source path, an async flag, a callback function, and a condition for loading. ```javascript Reveal.initialize({ dependencies: [ // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, // Interpret Markdown in
elements { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, // Syntax highlight for elements { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, // Zoom in and out with Alt+click { src: 'plugin/zoom-js/zoom.js', async: true }, // Speaker notes { src: 'plugin/notes/notes.js', async: true }, // MathJax { src: 'plugin/math/math.js', async: true } ] }); ``` -------------------------------- ### Get PDF as Buffer Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieves the PDF document as a buffer. ```APIDOC ## Get PDF as Buffer ### Description Retrieves the PDF document as a buffer. ### Method Signature ```javascript pdfMake.createPdf(docDefinition).getBuffer() ``` ### Response #### Success Response - **buffer** (Buffer) - The PDF document as a buffer. ``` -------------------------------- ### Get PDF as Blob Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieves the PDF document as a Blob object. ```APIDOC ## Get PDF as Blob ### Description Retrieves the PDF document as a Blob object. ### Method Signature ```javascript pdfMake.createPdf(docDefinition).getBlob() ``` ### Response #### Success Response - **blob** (Blob) - The PDF document as a Blob object. ``` -------------------------------- ### Deploy pdfmake Docs Webpages Source: https://github.com/pdfmake/docs/blob/master/README.md Build the static webpages for deployment using the Hugo build command. ```bash hugo --cleanDestinationDir ``` -------------------------------- ### Get PDF as URL Data Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieves the PDF document as a data URL. ```APIDOC ## Get PDF as URL Data ### Description Retrieves the PDF document as a data URL. ### Method Signature ```javascript pdfMake.createPdf(docDefinition).getDataUrl() ``` ### Response #### Success Response - **dataUrl** (string) - The PDF document as a data URL. ``` -------------------------------- ### Get PDF as Base64 Data Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieves the PDF document as a base64 encoded string. ```APIDOC ## Get PDF as Base64 Data ### Description Retrieves the PDF document as a base64 encoded string. ### Method Signature ```javascript pdfMake.createPdf(docDefinition).getBase64() ``` ### Response #### Success Response - **data** (string) - The PDF document as a base64 encoded string. ``` -------------------------------- ### Reveal.js Initialization with Dependencies Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/demo.html Initialize Reveal.js with various plugins and configurations. Ensure all necessary dependencies are loaded correctly for features like markdown support, syntax highlighting, and search. ```javascript // More info https://github.com/hakimel/reveal.js#configuration Reveal.initialize({ controls: true, progress: true, history: true, center: true, transition: 'slide', // none/fade/slide/convex/concave/zoom // More info https://github.com/hakimel/reveal.js#dependencies dependencies: [ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: 'plugin/search/search.js', async: true }, { src: 'plugin/zoom-js/zoom.js', async: true }, { src: 'plugin/notes/notes.js', async: true } ] }); ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md After creating the Hugo site, initialize it as a git directory to track changes. ```bash $ git init ``` -------------------------------- ### Initialize Reveal.js with Default Configuration Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/README.md Use this code to initialize Reveal.js with a comprehensive set of default configuration options. All options are optional and will use their specified defaults if not provided. ```javascript Reveal.initialize({ // Display presentation control arrows controls: true, // Help the user learn the controls by providing hints, for example by // bouncing the down arrow when they first encounter a vertical slide controlsTutorial: true, // Determines where controls appear, "edges" or "bottom-right" controlsLayout: 'bottom-right', // Visibility rule for backwards navigation arrows; "faded", "hidden" // or "visible" controlsBackArrows: 'faded', // Display a presentation progress bar progress: true, // Set default timing of 2 minutes per slide defaultTiming: 120, // Display the page number of the current slide slideNumber: false, // Push each slide change to the browser history history: false, // Enable keyboard shortcuts for navigation keyboard: true, // Enable the slide overview mode overview: true, // Vertical centering of slides center: true, // Enables touch navigation on devices with touch input touch: true, // Loop the presentation loop: false, // Change the presentation direction to be RTL rtl: false, // Randomizes the order of slides each time the presentation loads shuffle: false, // Turns fragments on and off globally fragments: true, // Flags if the presentation is running in an embedded mode, // i.e. contained within a limited portion of the screen embedded: false, // Flags if we should show a help overlay when the questionmark // key is pressed help: true, // Flags if speaker notes should be visible to all viewers showNotes: false, // Global override for autoplaying embedded media (video/audio/iframe) // - null: Media will only autoplay if data-autoplay is present // - true: All media will autoplay, regardless of individual setting // - false: No media will autoplay, regardless of individual setting autoPlayMedia: null, // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides autoSlide: 0, // Stop auto-sliding after user input autoSlideStoppable: true, // Use this method for navigation when auto-sliding autoSlideMethod: Reveal.navigateNext, // Enable slide navigation via mouse wheel mouseWheel: false, // Hides the address bar on mobile devices hideAddressBar: true, // Opens links in an iframe preview overlay previewLinks: false, // Transition style transition: 'slide', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom // Number of slides away from the current that are visible viewDistance: 3, // Parallax background image parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" // Number of pixels to move the parallax background per slide // - Calculated automatically unless specified // - Set to 0 to disable movement along an axis parallaxBackgroundHorizontal: null, parallaxBackgroundVertical: null, // The display mode that will be used to show slides display: 'block' }); ``` -------------------------------- ### Get PDF as Stream Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieve the PDF document as a stream. Streams are efficient for handling large amounts of data. ```javascript pdfMake.createPdf(docDefinition).getStream().then((stream) => { // ... }, err => { console.error(err); }); ``` -------------------------------- ### Get PDF as Blob Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieve the PDF document as a Blob object. Blobs are useful for handling binary data. ```javascript pdfMake.createPdf(docDefinition).getBlob().then((blob) => { // ... }, err => { console.error(err); }); ``` -------------------------------- ### Initialize Reveal.js with Dependencies Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/index.html Initialize reveal.js with essential plugins like Markdown support, notes, and syntax highlighting. The callback ensures syntax highlighting is initialized after the plugin loads. ```javascript Reveal.initialize({ dependencies: [ { src: 'plugin/markdown/marked.js' }, { src: 'plugin/markdown/markdown.js' }, { src: 'plugin/notes/notes.js', async: true }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } } ] }); ``` -------------------------------- ### Get PDF as URL Data Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieve the PDF document as a data URL, useful for embedding in iframes or other elements. ```javascript pdfMake.createPdf(docDefinition).getDataUrl().then((dataUrl) => { const targetElement = document.querySelector('#iframeContainer'); const iframe = document.createElement('iframe'); iframe.src = dataUrl; targetElement.appendChild(iframe); }, err => { console.error(err); }); ``` -------------------------------- ### Reveal.js Initialization with Dependencies Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/markdown/example.html Initializes Reveal.js with various configuration options and a list of dependencies for extending its functionality. Load order and conditions are important for plugin initialization. ```javascript Reveal.initialize({ controls: true, progress: true, history: true, center: true, // Optional libraries used to extend on reveal.js dependencies: [ { src: '../../lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'marked.js', condition: function() { return !!document.querySelector( '["data-markdown"]' ); } }, { src: 'markdown.js', condition: function() { return !!document.querySelector( '["data-markdown"]' ); } }, { src: '../highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '../notes/notes.js' } ] }); ``` -------------------------------- ### Get PDF as Buffer Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieve the PDF document as a buffer. This is commonly used in Node.js environments or for specific data processing. ```javascript pdfMake.createPdf(docDefinition).getBuffer().then((buffer) => { // ... }, err => { console.error(err); }); ``` -------------------------------- ### Import pdfmake and add vfs_fonts (ES Modules) Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/_index.md Import pdfmake and its default fonts, then explicitly add the virtual file system using ES module syntax. ```javascript import pdfMake from "pdfmake/build/pdfmake"; import pdfFonts from "pdfmake/build/vfs_fonts"; pdfMake.addVirtualFileSystem(pdfFonts); ``` -------------------------------- ### Initialize Reveal.js with Basic Transition Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/test/examples/embedded-media.html This is a basic Reveal.js initialization. It sets the presentation transition to 'linear'. ```javascript Reveal.initialize({ transition: 'linear' }); ``` -------------------------------- ### Get PDF as Base64 Data Source: https://github.com/pdfmake/docs/blob/master/content/getting-started/client-side/methods.md Retrieve the PDF document as a base64 encoded string. This is often used for data transmission. ```javascript pdfMake.createPdf(docDefinition).getBase64().then((data) => { alert(data); }, err => { console.error(err); }); ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/README.md After adding the theme as a submodule, initialize and update it for the parent git repository. ```bash $ git submodule init $ git submodule update ``` -------------------------------- ### PHP Function Example Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/plugin/markdown/example.html A basic PHP function definition with an array assignment. Ensure proper PHP syntax and context for execution. ```php public function foo() { $foo = array( 'bar' => 'bar' ) } ``` -------------------------------- ### Initialize Reveal.js Presentation Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/layouts/shortcodes/revealjs.html Initializes Reveal.js with various configuration options. Use this to set up controls, centering, history, progress, and transitions. It also includes conditional loading of optional libraries like Markdown support, syntax highlighting, zoom, and notes. ```javascript function initSlides() { Reveal.initialize({ embedded : true, controls : {{with .Get "controls"}}{{.|safeHTML}}{{else}}false{{end}}, center: {{with .Get "center"}}{{.|safeHTML}}{{else}}true{{end}} , history: {{with .Get "history"}}{{.|safeHTML}}{{else}}false{{end}} , progress: {{with .Get "progress"}}{{.|safeHTML}}{{else}}false{{end}} , transition: {{with .Get "transition"}}{{.}}{{else}}"concave"{{end}}, // theme: Reveal.getQueryHash().theme, // available themes are in /css/theme // Optional libraries used to extend on reveal.js dependencies: [ { src: '{{"revealjs/lib/js/classList.js"|relURL}}', condition: function() { return !document.body.classList; } }, { src: '{{"revealjs/plugin/markdown/marked.js"|relURL}}', condition: function() { return !!document.querySelector( '[\[data-markdown\]]' ); } }, { src: '{{"revealjs/plugin/markdown/markdown.js"|relURL}}', condition: function() { return !!document.querySelector( '[\[data-markdown\]]' ); } }, { src: '{{"revealjs/plugin/highlight/highlight.js"|relURL}}', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '{{"revealjs/plugin/zoom-js/zoom.js"|relURL}}', async: true, condition: function() { return !!document.body.classList; } }, { src: '{{"revealjs/plugin/notes/notes.js"|relURL}}', async: true, condition: function() { return !!document.body.classList; } } ] }); } ``` -------------------------------- ### Reveal.js Initialization with Transitions Source: https://github.com/pdfmake/docs/blob/master/themes/docdock/static/revealjs/test/examples/slide-transitions.html Configure Reveal.js with options for centering slides, enabling history, and setting transition effects. Uncomment lines to enable specific transition types or speeds. ```javascript Reveal.initialize({ center: true, history: true, // transition: 'slide', // transitionSpeed: 'slow', // backgroundTransition: 'slide' }); ``` -------------------------------- ### Get PDF as Data URL (Node.js) Source: https://context7.com/pdfmake/docs/llms.txt Generate a data URL for the PDF, which can be directly used in web contexts, such as embedding in an `