3 Replies - 222 Views - Last Post: 22 August 2012 - 09:02 AM Rate Topic: -----

#1 Ahud07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-April 10

Reading and/or converting a file

Posted 22 August 2012 - 08:08 AM

I cannot figure out how to read file type "file" it is a pdf and I am trying to read it in with pdfsharp and concatenate multiple pdfs but they are all file type "files"

57687182e41ed637e58fc97d6608402899f593 is one of the file names and it just says type "file".

I dont know if my code will help but here it is:
//gets the location of the file
string fileLocation
= Path.Combine(basePath, FileRepository.GetRepoFilePath(file.HashName));

PdfDocument inputDocument = PdfReader.Open(fileLocation, PdfDocumentOpenMode.Import);



fileLocation just returns "C:\\Users\\ahuddl2\\Documents\\presentation-admin-awh\\PresentationAdmin\\PresContent\\objects\\53\\57687182e41ed637e58fc97d6608402899f593"

and the PdfDocument gets the error "The file is not a valid PDF document"

I have tried just adding .pdf to the end of it and that doesnt work either.

Is This A Good Question/Topic? 0
  • +

Replies To: Reading and/or converting a file

#2 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4927
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: Reading and/or converting a file

Posted 22 August 2012 - 08:14 AM

If the filename doesn't have an extension then windows doesn't know what type to say it is. Just rename the file to include .pdf and Windows will think it is a pdf file.

That doesn't covert it. Renaming a .jpg to .pdf doesn't magically change the type, just what you are *saying* it is.


If after adding .pdf to the filename you can't open it with Adobe Acrobat Reader, then it really isn't a PDF.

Don't worry about programming with those files until you can confirm they are what you think they are.
Was This Post Helpful? 0
  • +
  • -

#3 Ahud07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-April 10

Re: Reading and/or converting a file

Posted 22 August 2012 - 08:42 AM

it is a pdf because I got it working with the exact same document using Aspose instead of PdfSharp, but Aspose is too expensive so I am trying the open source route.

 filePdfs.Add(new Document(fileLocation));


filePdfs is just a List<document> and the Document class is under Aspose so I cant use that.

That is just a hashname for the document the actual document name is PDF.pdf I just can read it with PdfSharp.
Was This Post Helpful? 0
  • +
  • -

#4 Ahud07  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 29-April 10

Re: Reading and/or converting a file

Posted 22 August 2012 - 09:02 AM

nevermind the code was fine, the pdf got corrupted somehow down the line, I tried it with a different pdf and it worked
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1