Product: PDFtron Python SDK
Product Version: PDFNetPython3 version 9.5.0.post1
Please give a brief summary of your issue:
We have a situation where we convert a .docx file to a .pdf file and want to support fonts available on Google Fonts without requiring our clients to embed the fonts beforehand. We do this by checking the fonts in the fontTable.xml in the .docx file and downloading the missing ones on Google Fonts.
This works without issue, but we do PDFNet.Initialize() when we initialize the function and then want to support calling it at any time through our API. But PDFNet.Initialize() also loads all available fonts and putting more fonts in after the initialization step isn’t recognised. We cannot use PDFNet.Terminate() because you can’t Initialize after Terminating.
As such, I want to ask if it’s possible for PDFTron to refresh and reload the available fonts at any point.
Please describe your issue and provide steps to reproduce it:
- Download Roboto from Roboto - Google Fonts and put it into the /usr/share/fonts/truetype folder on linux.
- Use PDFNet.Initialize()
- Convert a .docx containing the Roboto to PDF and see that it also exists in the converted PDF.
- Download Open Sans from Open Sans - Google Fonts and put it into the same folder in the same function after the initialization step.
- Convert a .docx containing the Open Sans font into PDF and see that it does not exist in the converted PDF because it was added after PDFNet.Initialize() loaded the fonts in.
Please provide a link to a minimal sample where the issue is reproducible:
from PDFNetPython3 import Convert, Optimizer, SDFDoc, PDFNet, PDFDoc
doc = PDFDoc()
Convert.OfficeToPDF(pdfdoc, "roboto.docx" ) #assuming roboto.docx exists with that font
Convert.OfficeToPDF(pdfdoc, "opensans.docx" ) #assuming opensans.docx exists with that font
pdfdoc.Save("fonts.pdf", SDFDoc.e_linearized)
pdfdoc.Close()