Click here to Skip to main content
15,886,002 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I want to download the azure storage pdf/tif file in local.
In pdf having many pages. I need to download only the first page.
I no need other pages.

What I have tried:

Dim size = CloudFile.Properties.Length
Dim buffer(size) As [Byte]
Dim Retval = cCloudFile.DownloadToByteArray(buffer, 0)
Dim fileName ="newfile.pdf"
File.WriteAllBytes(fileName, buffer)

but its download all the pages. I need to download first page only.
Posted
Updated 12-Jul-21 0:43am

1 solution

While I've not used it, just checking the documentation for CloudFile indicates to me that it is agnostic of the type of file it's downloading: it doesn't know whether the file is a text document, PDF, image, or spreadsheet. All it knows is that there's a file being stored containing data.

If you want to extract pages then you probably need to use a PDF library to interact with the file once all of the content has been downloaded. That does mean continuing to download the whole file, then pass the contents into a PDF parser library in order to extract the first page.

A quick Google seemed to show iTextSharp[^] is a popular library for doing this, though the NuGet page seems to indicate that it's now at EOL and iText 7 should be used instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900