Jump to content
You must now use your email address to sign in [click for more info] ×

Workaround for font problem with placed PDFs


fiëé

Recommended Posts

(This subforum is not really the right place for this, but I’d like to have it found where people might look for it.)


As most of you are aware, the Affinity apps can’t handle included fonts in PDFs, they always try to parse the PDF and do a good job about that, except they can’t use the embedded fonts but try to replace them with fonts installed/active on your system. Often you don’t have these fonts and must not replace them, e.g. if you get ads from a customer. There’s no possibility (yet) to “just place” a PDF as an image.

You could rasterize the PDF into a high resolution bitmap – but not with one of the Affinity apps, and if you wanted to use Photoshop, you wouldn’t use Affinity...

The best solution is to convert the text in curves. You can do that with Acrobat Pro, but I am here to avoid “Clay” apps. It’s easy with GhostScript on the command line:

gs -dNoOutputFonts -sDEVICE=pdfwrite -o Myfile_nofonts.pdf Myfile.pdf

Or to convert all files in a folder:

for PDF in *.pdf; do gs -dNoOutputFonts -sDEVICE=pdfwrite -o "${PDF/.pdf/_nofonts.pdf}" "$PDF"; done

You must first change into that folder, of course. And have GhostScript installed; you can get it via HomeBrew or MacPorts (there are also binary packages around I guess).

(EDIT: The quotes around $PDF are necessary if your file names contain spaces.)

Link to comment
Share on other sites

You can’t avoid getting your hands dirty on the command line (Terminal.app). You can read on the websites of HomeBrew and MacPorts how to install them. Which one you use is a matter of taste, please don’t anyone start a flame war! I’m used to MacPorts; HomeBrew users please help with that.

You need Apple’s development environment Xcode, you can install it via AppStore (or make a free account on developer.apple.com and download it there, as MacPorts suggests). You’ll never start that app yourself, but it contains the necessary compilers etc. that let Ports or Brew build programs from sources.

Xcode is a huge download, after it’s completed you can install the necessary command line programs and confirm the license. Open Terminal.app and type/copy these lines into its window (don’t forget to hit Return after each line):

xcode-select --install
xcodebuild -license

Then you download the pkg/dmg for your macOS version from https://www.macports.org/install.php and install it.

This installs the basics for using MacPorts, but no programs that you can use. First update the list of ports (packages), again in Terminal:

sudo port -v selfupdate

(You should run that every month or so if you want to stay up to date.)

sudo” means “superuser do“, i.e. “execute as administrator”, you need to enter your account password to proceed.
(And it means the whole thing won’t work if you don’t have an admin account, e.g. in a company, then whine at your admin until they yield and install that stuff for you.)

If that worked, you’re set to finally install what you wanted:

sudo ports install ghostscript

This will download the sources, compile them and install ghostscript in /opt/local/bin/. To check that, call

which gs

That should answer with “/opt/local/bin/gs”. If it doesn’t, close your Terminal window, open a new one and try again. Still doesn’t work? Then you can call gs with the full path (i.e. “/opt/local/bin/gs”) or add the path to your PATH variable (that determines where bash, that’s the “shell” running in Terminal, looks for commands/programs):

echo "export PATH=/opt/local/bin:$PATH" >> ~/.bash_profile

A lot of hassle for a single program, but MacPorts as well as HomeBrew offer a lot of tools and fun stuff, mostly ported from Linux or *BSD, that you might like. That’s a tad off topic here...

It’s probably easier to enter “ghostscript macos download” into your favourite search engine and choose one of the sites that offer free downloads. I don’t know which you can or should trust.

Link to comment
Share on other sites

If you want to reduce the quality of your data, then you’re free to render to a fixed resolution. It’s better to keep vectors as such, then the output device will use its maximum resolution.

GIF is nonsense anyway, it’s an outdated, RGB device dependend color palet format. Good enough for the web, but not for print. If you want to render, then at least use PNG.

Inkscape also needs the fonts installed, you gain nothing in comparison to AD. (In my limited experience, AD interprets PDFs better than Inkscape.)

Link to comment
Share on other sites

When you convert PDF to any image format (jpg, gif, tif, png ...), you loose the vectors and certain text or graphics might get pixelated when you increase the size. In short: Quality decreases.

I'm not sure what flattening a PDF does in Inkscape, but that might just be another workaround to achieve the same result as convertig it with GhostScript (even though 'flattening' normally is different to converting everything into curves, this might be an Inkscape specific term?).

Link to comment
Share on other sites

Not much of a work around. I tried using Publisher again today while exporting a large variable data and wanted to do a simple card and thought I would check out Publisher again. Dropped in the supplied PDF file and of course the font is messed up.

I mentioned this a while back during beta and thought I remembered some way of placing the PDF without Affinity trying to edit it... did I just make up some great idea to make me feel better about the software? If there is no way of doing this what is the hold up Affinity? Every time I try and use Publisher I hit a wall and find it unusable for what is extremely simple and basic tasks I do in Indesign. Not everything needs to be edited in Publisher, in fact it creates more headaches then I think it is worth. If was going to be setting up a catalogue or anything with a lot of imported PDF pages Publisher would be a train wreck. 

Simply put, we need to be able to place a PDF as is, no editing, just the PDF as is. 

Link to comment
Share on other sites

On 2/10/2020 at 9:37 AM, A_B_C said:

Just to add this. There is also a standard macOS ghostscript installer available, created by Richard Koch, University of Oregon:

https://pages.uoregon.edu/koch/

For people who don’t like to go through the command line. 😀

Thank you, I thought there was a good Mac installer around, but didn’t remember where. As a known name in the TeX community I’m sure we can trust Richard Koch. (I still prefer the command line way, since I use a lot of “ports” anyway and can update all of them automatically.)

Link to comment
Share on other sites

  • 3 weeks later...

I use Dorico, which exports to PDF or SVG natively. Neither of these formats works well in Affinity. Converting the PDF to pages of EPS files (with embedded fonts!) does seem to work well. But of course, you need a tool to do that. 

I also use Richard Koch's MacOS installer package for GhostScript, not because I don't like the CLI, but because I don't like both MacPorts and Homebrew! 🤣

For those on a Mac, once you have GhostScript installed, you can make a little Automator application that will outline any PDF that you drop onto it.

2054528966_Screenshot7.png.76e7f3519e62e75418f8f16e7f103323.png

Here's the text to copy and paste.

for f in "$@"
do
# Sanitize filename and save with new name
f=${f//\\}
filename="${f%.*}"
filename="$filename"" NoFonts.pdf"

/usr/local/bin/gs \
    -dNOPAUSE \
    -dBATCH \
    -dNoOutputFonts \
    -sDEVICE=pdfwrite \
    -sOutputFile="$filename" \
    "$f"
echo $f, $filename
done



 

Link to comment
Share on other sites

On 2/2/2020 at 11:00 PM, fiëé said:

Inkscape also needs the fonts installed, you gain nothing in comparison to AD.

Don't use it to export as raster, but to convert text to curves when fonts are missing, using the Poppler/Cairo option in the popup menu. (For this, they should be embedded in the document, as with AI.)

Link to comment
Share on other sites

6 hours ago, Wosven said:

Don't use it to export as raster, but to convert text to curves when fonts are missing, using the Poppler/Cairo option in the popup menu. (For this, they should be embedded in the document, as with AI.)

Indeed I was pretty certain that Inkscape did not need fonts installed to render PDFs and the output them to curves.

That said I will revert to the pdf2png method as I find the results more reliable.

Link to comment
Share on other sites

1 hour ago, Catshill said:

fonts installed to render PDFs

If fonts are embedded in the PDF, they don't need to be installed, if not embedded (= part or full fonts are in the PDF, and don't need to be installed), the PDF use the installed (if they are) fonts.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.