Click here to Skip to main content
11,705,998 members (58,660 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PDF Bitmap Metro
In above comment, there was some mistakes. Sorry!!!
I read PDF content as byte[] and then I use above method. It doesn’t work.
But for the image (png, bmp, jpeg) byet[], it works properly
Why it doesn’t work for PDF byte[].
-------------------------------------------------------------------------------------
FileOpenPicker filepickerOpen = new FileOpenPicker();
filepickerOpen.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filepickerOpen.ViewMode = PickerViewMode.Thumbnail;
filepickerOpen.FileTypeFilter.Clear();
filepickerOpen.FileTypeFilter.Add(".png");
filepickerOpen.FileTypeFilter.Add(".pdf");
StorageFile storage= await filepickerOpen.PickSingleFileAsync();

byte[] buffer = WindowsRuntimeBufferExtensions.ToArray(await FileIO.ReadBufferAsync(storage));
using (MemoryStream ms = new MemoryStream(buffer))
{
var ims = new InMemoryRandomAccessStream();
DataWriter dataWriter = new DataWriter(ims);
dataWriter.WriteBytes(buffer);
dataWriter.StoreAsync();
ims.Seek(0);
BitmapImage img = new BitmapImage();
img.SetSource(ims);
ImageDocument.Source = img;
}
-------------------------------------------------------------------------
Posted 28-Sep-12 1:15am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

A PDF file is not a simple byte array, it is a structured file consisting of different content elements. Go to the Adobe website and get a copy of the PDF documentation for further information.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As Richard already noted, A PDF file is not a simple byte array. This[^] article may shed some light on how you need to pursue this.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 208
1 Sergey Alexandrovich Kryukov 142
2 Inimicos 60
3 ppolymorphe 57
4 ProgramFOX 50
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100