PDF Experts- urgent advice?

H folks.
I spent a full year and quite a bit of cash getting hold of a custom font and rewriting my app so that I could use scalable custom glyphs in a PDF
It works very well.

BUT having shipped, I’m now hearing from people that if they modify the PDF in any way (highlight text, insert a page…) using PREVIEW on the Mac, all my custom glyphs completely disappear.
This makes the change look like a major bug rather than a major feature.
Yet I don’t know what I can do to prevent this happening… once the PDF exists its almost ‘out of my hands’
(It’s more likely a Preview bug than anything else: Wondershare PDF Editor doesn’t break it, nor does Adobe Acrobat)

Does anyone know what could cause this behaviour and how I can avoid it?

I’m using DynaPDFMBS

I insert the glyphs using calls like this:

   call p.SetFontAnsi symbolfont, p.kfsNormal, s, true, p.kcpGlyphIndexes

The ‘true’ parameter is an instruction to embed the font.

A sample file is here:
https://drive.google.com/file/d/1t3_EcIRs8BSkyR0g7JJl1G6pZPu4kl1g/view?usp=sharing

Stupid answer: lock the pdf (set the permissions to not modifiable) ?
Maybe using a password ? I never do that but I got some like that (read only).

Can’t reproduce on High Sierra with selecting text.

I’d recommend working with Christian directly to solve this issue. From what I read on the TidBits website Preview seems to have quite a few bugs with pdfs.

Interesting.

Select text, highlight in yellow, save, then reopen?

The file size drops, the symbols vanish
It seems like the embedded font is being lost in the process.
This happens even if the font is locally installed (just tested that in case that was the issue)

edit: yes, the embedded font is lost afterwards. (checked with http://pdf-analyser.edpsciences.org/)

Why SetFontAnsi and not SetFont?

And you really want to add glyphs directly?
Why not use kcpUnicode and draw text?

Than you don’t need to map text to glyphs yourself.

Because that worked to display the glyphs, but setfont didn’t, during development.
Sometimes they displayed different glyphs for the same character.

[quote]
And you really want to add glyphs directly?
Why not use kcpUnicode and draw text?[/quote]

Some of the symbols actually are put in using that method.
All vanish when Preview saves the file, but not when Adobe saves.
OSX 10.4 used to have a ‘save as PDFX’ option, Sierra does not.

As far as I can tell it is the loss of the embedded font which is the issue.
While I can with some justification say that the ‘bug’ lies in Preview, that won’t be believed by many customers.

i try insert blank page or insert another pdf and the glyph still show correctly on High Sierra but after saving, all the glyph disappear… just the grid is left. i was using Preview.

Well, what counts is what Adobe Reader displays.
Preview has a lot of bugs.

if you like to report a bug, please make a simple and small project to demonstrate it.

To whom?

I don’t think its a DynaPDFMBS bug, but if there is ‘something I can set on the PDF’ that avoids this issue I would be grateful to hear it.
So is this a small project to you, Christian, or are you suggesting I might get some response from Apple?

you can show me the problem, so I can check with Jens if we can fix something.
Or see if you do something completely different than we intended.

sent by email. Thanks for looking.

The sample code:

[code] dim pdf as dynapdf
pdf=new DynaPDF
call pdf.setpagemode( 2)
call pdf.CreateNewPDF specialfolder.desktop.child(“Sample.pdf”)
call pdf.AddFontSearchPath (specialfolderresources, false) //allow DynaPDF to see the font if not installed

//specialfolderresources is a method that returns the resources folder for windows or Mac, release or debug

call pdf.append
call pdf.SetFontAnsi “Ursasoftware”, pdf.kfsNormal, 12, true, pdf.kcpGlyphIndexes
call pdf.WriteText 10,pdf.GetPageHeight - 40,“hello there this is a test”
call pdf.endpage
call pdf.CloseFile
[/code]

Well, you use your own font.

If you use kcpGlyphIndexes, please also use the Write methods for Glyphs, e.g. using
WriteText(PosX as Double, PosY as Double, glyphs() as Integer) as Boolean

If you use kcpUnicode and your font has the characters and a correct unicode mapping table, the mapping would work.
But as far as I see, it either maps normal letters to symbols or it has no correct table.

WriteText(PosX as Double, PosY as Double, glyphs() as Integer) as Boolean

Are you saying if I do that , the problem goes away?

Edit: no, it doesn’t solve the problem.
It’s just a different way to get the glyph into the document.

Interesting, and probably simpler than what I have been doing.
But

dim glyphs() as integer glyphs.Append 67 call pdf.WriteText (10,pdf.GetPageHeight - 40, glyphs)

still creates a PDF where the problem persists, sadly.

I could in theory keep the glyphs by using DynaPDFGlyphOutlineMBS
And then Drawglyph

However, the result is then something that cannot be selected and highlighted, which is the purpose of using them as text. :frowning:

Well, again, I think the font does not have the correct unicode map.
You can use the string variant of the functions and pass text of course, but I don’t expect that will work well.

It does.

(I spent a long time on that)
But it’s not the cause of the font going missing.
That happens if I embed even a single character, and unicode functions.

Lots of testing later:
Preview is pretty poor.

Sam Rowlands recently revealed that the older PDFKit version has been replaced by the code from iOS and Apple have apparently damaged the PDF engine in OSX
Looks like this is one of the casualties.

Adobe works, and I found a couple of readers on iOS that also work properly.
So I need to have my pre-emptive ‘apologies for Apple’ ready. Sigh

You can use our MBS DynaPDF Plugin in Pro edition to render PDFs. That gives you a consistent behavior for all platforms.

I know. Thanks.
But the issue arises ‘after the PDF is out of my hands’ … the PDF files will be emailed to other people, and used on desktop and tablets.

I can say that the bug is in Preview. There are many similar reports of it losing OCR data from other apps too.
Nothing I can do is going to make Preview work, so it becomes a documentation thing

This thread is old, but looking at something unrelated today I found out about the changes to PDFkit in mac OS since 10.12 @Jeff Tullin is referring to and I thought it could help complement the information in the thread for future users.

If this is true it’s a shame. PDF handling was one of the stars of Mac OS and while cross-compatibility is great, replacing a capable library with a mediocre one is always a bad step back.