Link to home
Start Free TrialLog in
Avatar of cyimxtck
cyimxtckFlag for United States of America

asked on

Cannot locate resource URI when it clearly exists

For some reason I cannot get the URI to locate a file.

Stream stream = Application.GetResourceStream(new Uri("D:\\MultipageDocument.pdf", UriKind.Relative)).Stream;

Here is where it bombs regardless of what I try to use; we have tried embedding into the app, use a drive letter, Relative, Absolute, nothing works.  We are getting "Cannot find resource" when it is truly there.

Stream stream = Application.GetResourceStream(new Uri("Viewer_PDF, PDF/MultipageDocument.pdf", UriKind.Relative)).Stream;

Any help would be greatly appreciated.
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Please let me know if the file's location is under your app's root directory or somewhere else in the file system?
Avatar of cyimxtck

ASKER

After hours of playing with it, I was able to get this to work:

                var str = Application.GetRemoteStream(new Uri("pack://siteoforigin:,,,/pdf/MultipageDocument.pdf", UriKind.Absolute));

                Stream stream = str.Stream;
                var rdr = stream.ReadByte();

But I cannot read the PDF file text from the stream to put it into a text file.
You can not read PDF's text like that. PDF is a binary format you will have to use a paid or free PDF component to do that. I suggest you look at : https://itextpdf.com/. They have both, open source, community supported library as well as commercially licensed library. You can choose as per your needs. There are other paid and free solutions available as well.
We were trying with Telerik controls in:

RadFixedDocument document = new PdfFormatProvider(stream, FormatProviderSettings.ReadOnDemand).Import();

iText was a company we reached out to but cannot find the open source version of their code?

Do you have any idea where to find that?

ALL we want to do is read a PDF to text.

Thanks for your help,

B
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a ton!
You are welcome :)