Passing value from external function to document function

Community Beginner ,
Mar 20, 2021 Mar 20, 2021

Copy link to clipboard

Copied

Hi,

I am using below function to open pdf using Embed PDF API by using Session and Authentication.

document.addEventListener("adobe_dc_view_sdk.ready", function () {

	/* The PDF embed mode option here */
	const viewerConfig = {
		embedMode: "FULL_WINDOW",
		defaultViewMode: "FIT_PAGE",     //FIT_WIDTH
		showLeftHandPanel: true,
		showAnnotationTools: true,
		showDownloadPDF: true,
		showPrintPDF: true,
		showPageControls: true,
		showDisabledSaveButton: true,
		downloadWithCredentials: true
	};

	/* Initialize the AdobeDC View object */
	var adobeDCView = new AdobeDC.View({
		/* Registered client id */
		clientId: "yourCliendID",
		/* The div id in which PDF should be rendered */
		divId: "adobe-dc-view"
	});

	/* Invoke the file preview API on Adobe DC View object */
	adobeDCView.previewFile({
		/* Pass information on how to access the file */
		content: {
			/* Location of file where it is hosted */
			location: {
			    url: localPDFUrl,
			    headers: [
			        {
			            key: 'ASP.NET_SessionId',
			            value: currSessionID
			        },
			        {
			            key: '.ASPXAUTH',
			            value: currAuthToken
					},
		/* Pass meta data of file */
		metaData: {   
			/* file name */
			fileName: pdfFileName
		}
	}, viewerConfig);
});

As you can see from the above code, I need to pass below variable values from outside function. How can I pass the values from external function to above document function?

  1. localPDFUrl
  2. currSessionID
  3. currAuthToken
  4. pdfFileName

 

Please suggest.

Krunal
TOPICS
General, How to, PDF Embed API

Views

43

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Community Beginner , Mar 24, 2021 Mar 24, 2021
Removed document.addEventListener and created it as a normal function as below-function previewFile() {}and call the same from other event where necessary by passing all values or accessing it directly inside function previewFile.Thanks.

Likes

Translate

Translate
Community Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Any Suggestions or Comments?

Krunal

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

Removed document.addEventListener and created it as a normal function as below-

function previewFile() {}

and call the same from other event where necessary by passing all values or accessing it directly inside function previewFile.

Thanks.

Krunal

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines