Skip to main content
Participant
March 31, 2022
Answered

Is there a way to get the filesize in the PDF Embed API

  • March 31, 2022
  • 1 reply
  • 553 views

Hi. I am dynamically loading a file in the PDF Embed API. I can get the file metadata (eg the page count etc). However, I don't see any option to get the file-size.

 

My use-case requires me to check the file-size - and only show the annotation tools for files that are smaller than 5mb.

This topic has been closed for replies.
Correct answer Akshay Rohatgi

Hi @vmit 
Thanks for using PDF Embed API.  Currently PDF Embed API doesn't provides any API to get the file size. 

 

However, for your use you can try out below suggestions:

  1. Download the file as blob and read the file size as shown here https://developer.mozilla.org/en-US/docs/Web/API/Blob/size . Since, you have the file size now, you can decide whether to enable Annotation Tools or not while invoking the PDF Embed API.
  2. Now, you can pass the same file blob from step 1 to the PDF Embed API using https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos/#file-promise 


Feel free to reach out incase of any queries / concerns.

1 reply

Akshay Rohatgi
Adobe Employee
Akshay RohatgiCorrect answer
Adobe Employee
April 1, 2022

Hi @vmit 
Thanks for using PDF Embed API.  Currently PDF Embed API doesn't provides any API to get the file size. 

 

However, for your use you can try out below suggestions:

  1. Download the file as blob and read the file size as shown here https://developer.mozilla.org/en-US/docs/Web/API/Blob/size . Since, you have the file size now, you can decide whether to enable Annotation Tools or not while invoking the PDF Embed API.
  2. Now, you can pass the same file blob from step 1 to the PDF Embed API using https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos/#file-promise 


Feel free to reach out incase of any queries / concerns.

vmitAuthor
Participant
April 1, 2022

Thank you. We will implement this.