Comments (12)
That is not possible right now.
It might be possible when fpdf_sysfontinfo.h
is implemented, but I do not know for sure, it might be that pdfium will always load the embedded font when it's available.
I would have to look into it, will let you know!
from go-pdfium.
WASM uses a linux-like build, so the font folders the same as the Linux build:
- /usr/share/fonts
- /usr/share/X11/fonts/Type1
- /usr/share/X11/fonts/TTF
- /usr/local/share/fonts
If you provide your own FSConfig
in the initialization, make sure that the font folder is mounted into the available folders for pdfium.
from go-pdfium.
pdfium looks in a few different folders for fonts (depending on your OS):
https://pdfium.googlesource.com/pdfium/+/refs/heads/main/core/fxge/linux/fx_linux_impl.cpp#169
https://pdfium.googlesource.com/pdfium/+/refs/heads/main/core/fxge/apple/fx_apple_platform.cpp#148
You can also give extra paths in go-pdfium to look for fonts when initializing the library:
https://github.com/klippa-app/go-pdfium/blob/main/pdfium.go#L10
Generally it should be enough to have a default set of fonts, but I did notice it might help to install msttcorefonts
to get some Windows fonts because some PDF renderers do not embed fonts and expect the Windows fonts to always be available.
from go-pdfium.
@jerbob92
Thank you for your reply.
I am using Wasm, is it the same?
from go-pdfium.
Thank you very much!
How should alternative fonts be specified? 🙇♂️
from go-pdfium.
pdfium doesn't expose an easy method to control that, the only way to do it is by implementing fpdf_sysfontinfo.h
, which is one of the few things that this library did not implement (yet), due to the complicated nature of those methods. Those methods basically allow you to build your own font mapper.
I might look into adding support for this later, but generally PDF's should not use fonts that aren't widely installed on machines as it will cause render issues, that's why PDF's embed fonts if they are not installed by default on machines.
If a font isn't embedded, it first tries to search in the specified folders for the requested font. Afaik pdfium tries to fall back to Arial when it can't find the requested font.
Could you try to check which font the PDF is trying to load?
from go-pdfium.
I have to process PDFs that are given to me by another user, and in some cases the PDFs use commercial fonts, and I would like to use an alternative font.
from go-pdfium.
@nonchan7720 so you mean that these PDF's have the font embedded but you want to replace them anyway?
from go-pdfium.
Yes, it is.
from go-pdfium.
I look forward to the day when we can get good information!
from go-pdfium.
I did some tests and got a nice starting point (in the CGO implementation) with the implementation of fpdf_sysfontinfo.h
. However, I have sad news for you. Pdfium only calls the custom font mapper when it renders a font that is not embedded inside the PDF.
I will probably complete the implementation (for WASM too) while I'm at it, but it won't be useful for you I'm afraid.
You could try to ask here for pdfium to add a feature to also use the custom font mapper for embedded fonts.
from go-pdfium.
I will close this issue for now.
from go-pdfium.
Related Issues (20)
- how to run a demo HOT 8
- segmentation violation when using a custom ReadSeeker HOT 2
- api:GetPageTextStructured The extracted information has repeat areas HOT 7
- Android failed to use webassembly HOT 1
- Any plans for XFA/V8? HOT 5
- How to install and configure the windows Msys2 environment
- Web assembly implementation build error after v1.12.0 upgrade HOT 4
- How do I draw a rectangular shape? HOT 15
- Bug: PDF objects are not added.
- Add Mac OS arm64 build support HOT 7
- A size of 0 in FPDF_GetMetaText in GetMetaData should not result in an error HOT 1
- improve doc: how to choose the right parameters for multithreading HOT 22
- windows 7 32 compile error HOT 2
- Concurrent read and write to FileReaders - Web Assembly HOT 3
- Library not loaded on macOS HOT 4
- Retrieving "structured" paths HOT 1
- WebAssembly: module closed with exit_code(1) HOT 7
- I need sample code to insert an Image into a page. HOT 13
- Pdf parser HOT 1
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 go-pdfium.