1

I have several PDF documents containing maps. Which one of these is the best option and how can I implement it:

  1. Launch the PDF file to show the map. I don't think this is best practice however as I think you may need Adobe Reader installed (Not sure about this).
  2. Convert the image to an image and show it inside a ScrollViewer. However, I am not able to convert it to an image with sufficient high enough resolution. If I do this What resolution should I use anyway?
  3. I understand it is possible to convert a PDF to XAML. I can then show the XAML directly in a ScrollViewer. However, this process is slow and laborious and the XAML generated would be pretty massive. Not sure what the performance would be like.
  4. A fourth option, is toconvert the maps to XPS format and then try to launch the document. I'm not sure if this will work and if XPS is universally supported.
Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311

2 Answers2

4
  1. Yes, the client needs some PDF reader installed and set by default for opening .pdf files for this scenario. If you want to go this way, just use Process.Start(pdfFilePath). This will throw an exception if user doesn't have application associated with pdf. If you want to show "Open with" dialog instead, use ProcessStartInfo.ErrorDialog.

  2. This is probably the best option. You need to render PDF into an image with a good resolution. So you need a PDF library. I guess you're using C#, so you can go with PdfSharp or ITextSharp, but note that ITextSharp is paid-for if you use it in a commercial app. I don't know your requirements on resolution, but you can try to get user's screen resolution and decide on that.
    You need pdf rasterization, check http://code.google.com/p/lib-pdf or http://stefanochizzolini.it/en/projects/clown

  3. As far as I know, doing this in automatic mode is impossible. PDF is a pretty complex format, that allows really insane formatting, which is hard to reproduce with anything else. There are ways to generate xaml from pdf, but they require manual labor to fix xaml issues after this conversion, so I guess this is not what you want for rendering maps.

Community
  • 1
  • 1
ptkvsk
  • 2,096
  • 1
  • 25
  • 47
  • This is for a new WinRT app. I have tried number 3 a very long time ago and remember it being quite difficult but the results were ok. It generated a rediculous amount of XAML though. I have also added number four which I have read about. A Windows 8 screen can be any size so not sure about Number 2. – Muhammad Rehan Saeed Sep 24 '12 at 08:34
  • 1
    Oops, sorry for confusion. yms is right. You need pdf rasterization, check http://code.google.com/p/lib-pdf/ or http://www.stefanochizzolini.it/en/projects/clown/ – ptkvsk Sep 24 '12 at 13:37
1

After further investigation. The best option is to convert your PDF's to XPS format. Then launch these files. There is a XPS viewer built into every Windows 8 installation. The major advantage to this is that it will support any screen resolution and is dead easy to implement.

Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311