How to use pdfobject - 9 common examples

To help you get started, we’ve selected a few pdfobject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / mini-browser / src / browser / mini-browser.ts View on Github external
protected async go(location: string, register: boolean = false, showLoadIndicator: boolean = true): Promise {
        if (location) {
            try {
                this.toDisposeOnGo.dispose();
                const url = await this.mapLocation(location);
                this.setInput(url);
                if (this.getToolbarProps() === 'read-only') {
                    this.input.title = `Open ${url} In A New Window`;
                }
                if (showLoadIndicator) {
                    this.showLoadIndicator();
                }
                if (url.endsWith('.pdf')) {
                    this.pdfContainer.style.display = 'block';
                    this.frame.style.display = 'none';
                    PDFObject.embed(url, this.pdfContainer, {
                        // tslint:disable-next-line:max-line-length
                        fallbackLink: `<p style="padding: 0px 15px 0px 15px">Your browser does not support inline PDFs. Click on this <a href="[url]">link</a> to open the PDF in a new tab.</p>`,
                    });
                    this.hideLoadIndicator();
                } else {
                    if (this.props.resetBackground === true) {
                        this.frame.addEventListener('load', () =&gt; this.frame.style.backgroundColor = 'white', { once: true });
                    }
                    this.pdfContainer.style.display = 'none';
                    this.frame.style.display = 'block';
                    this.frame.src = url;
                    // The load indicator will hide itself if the content of the iframe was loaded.
                }
                // Delegate all the `keypress` events from the `iframe` to the application.
                this.toDisposeOnGo.push(addEventListener(this.frame, 'load', () =&gt; {
                    try {
github eclipse-theia / theia / packages / mini-browser / src / browser / mini-browser-content.ts View on Github external
try {
                this.toDisposeOnGo.dispose();
                const url = await this.mapLocation(location);
                this.setInput(url);
                if (this.getToolbarProps() === 'read-only') {
                    this.input.title = `Open ${url} In A New Window`;
                }
                clearTimeout(this.frameLoadTimeout);
                this.frameLoadTimeout = window.setTimeout(this.onFrameTimeout.bind(this), 4000);
                if (showLoadIndicator) {
                    this.showLoadIndicator();
                }
                if (url.endsWith('.pdf')) {
                    this.pdfContainer.style.display = 'block';
                    this.frame.style.display = 'none';
                    PDFObject.embed(url, this.pdfContainer, {
                        // tslint:disable-next-line:max-line-length quotemark
                        fallbackLink: `<p style="padding: 0px 15px 0px 15px">Your browser does not support inline PDFs. Click on this <a href="[url]">link</a> to open the PDF in a new tab.</p>`
                    });
                    clearTimeout(this.frameLoadTimeout);
                    this.hideLoadIndicator();
                    if (!preserveFocus) {
                        this.pdfContainer.focus();
                    }
                } else {
                    this.pdfContainer.style.display = 'none';
                    this.frame.style.display = 'block';
                    this.frame.src = url;
                    // The load indicator will hide itself if the content of the iframe was loaded.
                    if (!preserveFocus) {
                        this.frame.addEventListener('load', () =&gt; {
                            const window = this.frame.contentWindow;
github DefinitelyTyped / DefinitelyTyped / pdfobject / pdfobject-tests.ts View on Github external
function test_embedding_with_all_parameters() {
    var el:HTMLElement = PDFObject.embed("url", ".css-selector", {
        "height": "200px"
    });
}
github DefinitelyTyped / DefinitelyTyped / pdfobject / pdfobject-tests.ts View on Github external
function test_supports_pdfs() {
    var supportsPDFs:boolean = PDFObject.supportsPDFs;
}
github DefinitelyTyped / DefinitelyTyped / pdfobject / pdfobject-tests.ts View on Github external
function test_pdf_object_version() {
    var version:string = PDFObject.pdfobjectversion;
}
github man-group / pynorama / pynorama-js / src / viewers / pdf.jsx View on Github external
componentDidMount() {
    PDFObject.embed(this.props.data, this.pdfElement);
  }
github onfido / onfido-sdk-ui / src / components / Confirm / PdfPreview.js View on Github external
embedPDF(previewUrl){
    PDFObject.embed(previewUrl, `#${this.id}`, this.options);
  }
github MicroPad / Web / app / src / react-web / components / note-viewer / elements / PdfElementComponent.tsx View on Github external
private embedPdf = () => {
		const { element, noteAssets } = this.props;
		const asset = noteAssets[element.args.ext || ''];

		if (this.isEditing || !this.viewerElementRef || !asset) return;

		PDFObject.embed(asset, this.viewerElementRef, {
			fallbackLink: false,
			PDFJS_URL: './assets/pdfjs/web/viewer.html',
			forcePDFJS: !!window['isElectron']
		});
	}

pdfobject

A lightweight JavaScript utility for dynamically embedding PDFs in HTML documents

MIT
Latest version published 10 months ago

Package Health Score

66 / 100
Full package analysis