Comments (8)
Oh, I've missed some important message in the first comment.
Actually, I've followed “Building libmupdf” and "Tips for compiling MuPDF 1.18.0" section in Readme.md, same error.
Both libmupdf.lib and MuPdfWrapper are compiled for x86 arch, double checked by dumpbin.exe /headers tool.
So I think if libmupdf and the wrapper combination can really run in x86 windows.
from mupdfcore.
Current progress,
Found the key of above exception,
int CreateContext(long store_size, const fz_context** out_ctx) in wrapper declared the store_size parameter as long, which in x86 arch is actually 4 bytes integer, but in MuPdfCore, it is declared as Ulong, which is 8 bytes long.
After modify the declaration, CreateContext return success, but CreateDocumentFromStream return ERR_CANNOT_OPEN_FILE. Yes, it's the error I used to get yesterday in another issue. Should do more investigation.
from mupdfcore.
Hi again! Yes, I'm afraid you will encounter similar issues throughout the whole library: the problem is that in C++ data types can have different sizes depending on the architecture (as you noticed), while in C# they always have the same size.
Making the library work with both x86 and x64 without having two separate code branches might be achievable (see here for ideas for an initial approach), but it will require a non-insignificant amount of work... Which is why I didn't do it in the first place, considering that most machines now should be x64-capable 😅
I may have to think back about this when Microsoft release .NET 6 with native support for Apple silicon Macs (because I need native support for another project), but I'm hoping that since that is still an Arm64 architecture it won't be much work.
Anyways, are you sure you need to do this? Even if your application is compiled with AnyCPU (and you get a warning because this is not compatible with MuPDFCore's x64 architecture), if the program is running on an x64 machine it should work without issues (and I expect that nowadays there are only very few computers actually running 32-bit Windows...)
If you're sure you want to do this, you will likely have to debug the whole MuPDFWrapper native code for issues like this. I would suggest adding lines that print something to the console in multiple places within the C++ code, so that you can figure out where the errors are occurring. I would also recommend, as far as possible, not to touch the C++ code, but rather implement the fixes in the C# code (I think it's easier for the C++ code to fail "silently", while .NET will usually give some sort of "complaint" when something is wrong).
Let me know if you succeed!
from mupdfcore.
Thanks again, Giorgio. ^_^
Your suggestion is quite right. Actually, the application must work with a thirdparty hardware, they can not supply a x64 native driver dll, So I have to implement the x86 version for the full project.
I'll try to debug and fix the native interface in MuPdfCore, if no success, the last way is wrap the third party native dll with a 32 bit .net class and use RPC to communicate with.
from mupdfcore.
Finally, the library worked in my usecase. Not tested completely.
To avoid maintain two versions of MuPDFCore and follow your future updates, I decided to keep MuPDFCore original, modify the wrapper source.
Actually it's easy than I think, just modify the interface function declaration from size_t to uint64_t, long to uint64_t, it's working in both x86 and x64 arch with same source.
Thanks.
from mupdfcore.
That's good news!
The only thing to look out for is that the where I was using size_t
, this was because the MuPDF library calls that the wrapper performs also have size_t
parameters... So what you did might work in most cases, but it wouldn't surprise me if some weird thingsTM happen in edge cases 😅
In any case, I think we can close this, right?
from mupdfcore.
Yes, I've not test it by large PDF file, because my PDF file to render is code generated report, less than 100k in size.
from mupdfcore.
Hi! I think you have already solved your issue, but I just wanted to mention that in version 1.4.0 I have finally added native support for 32-bit Windows (and a few more architectures)!
from mupdfcore.
Related Issues (20)
- How to improve or decrease png quality? HOT 3
- .dll problem when released HOT 3
- Method not found: 'Void MuPDFCore.MuPDFContext..ctor(Int64)'. HOT 2
- Cannot open document HOT 5
- Other output image formats HOT 3
- Accept and return ReadOnlySpan<byte> instead of IntPtr HOT 3
- do you support reading encrypted PDF files? HOT 3
- Install MuPDFCore in Blazor WebAssembly HOT 4
- PDFViewerDemo cannot chanage pages HOT 2
- show pdf files continuously HOT 1
- Don't work with musl-based linux distros HOT 2
- MuPDFCore.dll in MuPDFCore NuGet package 1.7 has no strong name HOT 3
- blank area above PDFRender
- using MuPDFRenderer control on Avalonia 11 HOT 3
- Set anti-aliasing level HOT 2
- Is there a way to support iOS and Mac Catalyst? HOT 1
- is there a plan to support the outline HOT 3
- Do you support deleting pages HOT 1
- How to extract font name, font binary data, font 2D coordinates, image binary data, image 2D coordinates within a PDF page?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mupdfcore.