Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem locating the mupdfcpp64.dll #144

Open
tranlm opened this issue Dec 4, 2024 · 1 comment
Open

Problem locating the mupdfcpp64.dll #144

tranlm opened this issue Dec 4, 2024 · 1 comment

Comments

@tranlm
Copy link

tranlm commented Dec 4, 2024

I'm trying to access all the text in my pdfs via the following (using MuPDF.NET 2.1.2):

            List<string> fileContent = [];
            MuPDF.NET.Document doc = new(path);
            foreach (var page in doc.GetPages(0, doc.PageCount, 1))
            {
                TextPage tpage = page.GetTextPage();
                fileContent.Add(tpage.ToString() ?? "");
            }

However, I'm getting an error from the package. I

2024-12-03 20:42:21 -08:00 <:1> [ERR] Error in SaveLibrary: "The type initializer for 'MuPDF.NET.Document' threw an exception." (at LibraryService.LibraryService+<SaveLibrary>d__30.MoveNext())
System.TypeInitializationException: The type initializer for 'MuPDF.NET.Document' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'MuPDF.NET.Utils' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'MuPDF.NET.ColorSpace' threw an exception.
 ---> System.UnauthorizedAccessException: Access to the path 'C:\windows\system32\mupdfcpp64.dll' is denied.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.Create(String path)
   at MuPDF.NET.Utils.LoadEmbeddedDll()
   at MuPDF.NET.ColorSpace..cctor()
   --- End of inner exception stack trace ---
   at MuPDF.NET.ColorSpace..ctor(Int32 type)
   at MuPDF.NET.Utils..cctor()
   --- End of inner exception stack trace ---
   at MuPDF.NET.Utils.InitApp()
   at MuPDF.NET.Document..cctor()
   --- End of inner exception stack trace ---

From the call stack, it looks like you're trying to LoadEmbeddedDll, which is then trying to Create a file within C:\windows\system32, which would require admin privileges. Is this what you intended?

@jamie-lemon
Copy link
Contributor

@tranlm How do you define your variable for path here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants