Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wmjordan/sharpmupdf
Compiled DLL for MuPDF (https://github.com/ArtifexSoftware/mupdf) with a C# P/Invoke demo program
https://github.com/wmjordan/sharpmupdf
mupdf pdf
Last synced: 4 days ago
JSON representation
Compiled DLL for MuPDF (https://github.com/ArtifexSoftware/mupdf) with a C# P/Invoke demo program
- Host: GitHub
- URL: https://github.com/wmjordan/sharpmupdf
- Owner: wmjordan
- License: agpl-3.0
- Created: 2020-11-17T03:33:17.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T02:21:20.000Z (3 months ago)
- Last Synced: 2025-01-22T18:08:13.408Z (12 days ago)
- Topics: mupdf, pdf
- Language: C++
- Homepage:
- Size: 289 KB
- Stars: 66
- Watchers: 10
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Sharp MuPDF
Sharp MuPDF demonstrates how to compile MuPDF source code into a dynamic link library and consume its functionality in .NET.
## Compile
To compile the source code.
1. Install _Visual Studio 2019_ or newer versions.
2. Install _python 3_ (`Python.exe` must be accessible via the PATH environment variable).
3. Open the `MuPDF.sln` in the solution folder with Visual Studio.
4. Compile the solution.
5. During compilation, Python will be called to generate the definition file for the target dll file.
6. Results:
`MuPDFLib` project will produce two DLL files for mupdf, one for x86 and the other for x64.
`Demo` project contains some code to demonstrate how to use functions in MuPDFLib.dll
## System font loading
In order to support loading system fonts for documents with unembedded fonts and avoid the performance lost across DLL files, a code file named `mupdf_load_system_font.c` shall be compiled with the `libmupdf` project.
We have to modify that project and reference the code file from `MuPDFLib\Document\mupdf_load_system_font.c`.
That code file is copied from project *SumatraPDF* and all credits goes to them.
## Shrinking MuPDFLib.dll
Open the property page for the `libmupdf` project.
Add `;TOFU;TOFU_CJK_EXT` to _C/C++_/_Preprocessor_/_Preprocessor Definitions_ for _All Configurations_ and _All Platforms_ in configuration manager.
So you can exclude several huge fonts from the DLL.
For more information, see `config.h` file within the `!include/fitz` folder in `libmupdf` project.
## .NET assembly reference of MuPDFLib.dll
From version 2.* on, it is possible to reference MuPDFLib.dll as a .NET assembly, since it is compiled with C++/CLI.
If you redistribute the MuPDFLib.dll which is referenced as a .NET assembly in your application, your users may encounter a problem that *the MuPDFLib.dll could not be loaded*.
To fix the problem, enclose the Visual C++ Runtime library files with your redistribution. At least, `vcruntime140.dll` and `msvcp140.dll` are the minimum set of required DLL files.
## Update source code
1. Use `git pull` command to update the repository.
2. To update source code, tags and submodules, use:
``` bash
cd mupdf
git pull origin master --recurse-submodules
```It is possible that local modifications have been made. To discard local modifications when updating submodules, use the following command before `pull`ing from master:
``` bash
git reset --hard --recurse-submodules origin/master
git reset --hard --recurse-submodules
```To fetch remote tags, use:
``` bash
git fetch origin --tags
```Afterwards, it is possible to check out the newly added tags:
``` bash
git checkout
```Alternatively, we can also execute the following commands against each changed files:
``` bash
git reset HEAD
git checkout --
```We may see the following warning when we `pull` from master:
```
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.
```To fix this, run the following commands:
``` bash
git fetch --all
git reset --hard origin/master
```Afterwards, we can `pull` from master then.
3. The first a few lines in the `name-table.h` file have slight modifications from the original one in the `libmupdf` project, for the sake of making field names valid in .NET. Check whether it is changed and make the corresponding synchronization. To facilitate this operation, run the `sync_name_table.py` script within the `MuPDFLib` project folder.
## Git Proxy
If accessing the Internet requires HTTPS proxy, use the following command:``` bash
git config --global http.proxy
git config --global https.proxy
```When you are done, use the following command to reset the proxy to default:
``` bash
git config --global --unset http.proxy
git config --global --unset https.proxy
```## License
This project follows the license terms of *MuPDF*.