getImageUrl Method

Summary

Gets a URL to the raster image for this page.

Syntax
TypeScript
JavaScript
DocumentPage.prototype.getImageUrl = function() 
getImageUrl(): string; 

Return Value

A string representing the URL to the raster image for this page.

Remarks

For more information on this method or to load the image through the Document Library, see GetThumbnailImageElement.

Refer to Image Loading Using LEADTOOLS Document Library and Document Loading Using LEADTOOLS Document Library for more information.

Example

This example shows will load a PDF document and then load a page into a HTML Image element.

Start with the example from LEADDocument and replace all the code inside the example function (search for the "// TODO: add example code here" comment) with the following code:

TypeScript
JavaScript
var url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
log("Loading document..."); 
lt.Document.DocumentFactory.loadFromUri(url, null) 
   .done(function (doc) { 
      log("Done."); 
 
      var pageNumber = 2; 
      var docPage = doc.pages.item(pageNumber - 1); 
      // Instead of loading through the Documents Library, use an img ourselves 
      var pageImageUrl = docPage.getImageUrl(); 
      img.onload = function () { 
         log("Loaded!"); 
      }; 
      img.onerror = function () { 
         log("Failed."); 
      }; 
      log("Loading: " + pageImageUrl); 
      img.src = pageImageUrl; 
   }) 
   .fail(showServiceError); 
class DocumentPage_GetImageUrlExample { 
    private imgEle: HTMLElement; 
    public constructor() { 
        lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt", "EVAL", null); 
    } 
 
    public run(buttonID: string, imgID: string) { 
        const exampleButton = document.getElementById(buttonID); 
        exampleButton.onclick = this.onClick; 
 
        this.imgEle = document.getElementById(imgID); 
        console.log(this.imgEle); 
    } 
 
    onClick = () => { 
        //Load the initial document 
        const url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
        const img = (this.imgEle as HTMLImageElement); 
 
        log("Loading document..."); 
        lt.Document.DocumentFactory.loadFromUri(url, null) 
            .done((doc) => { 
                log("Done."); 
 
                const pageNumber = 2; 
                const docPage = doc.pages.item(pageNumber - 1); 
                // Instead of loading through the Documents Library, use an img ourselves 
                const pageImageUrl = docPage.getImageUrl(); 
                img.onload = () => { 
                    log("Loaded!"); 
                }; 
                img.onerror = () => { 
                    log("Failed."); 
                }; 
                log("Loading: " + pageImageUrl); 
                img.src = pageImageUrl; 
            }) 
            .fail(showServiceError); 
    } 
} 

Requirements

Target Platforms

Help Version 20.0.2019.4.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly