views:

384

answers:

2

I have pdf file using only 2 type of fonts.

But when exporting the pdf to xps format, there are odttf files as many as glyphs elements in generated xps document.

Now I want every glyphs with the same font type to have the same FontUri value. But how to identify if 2 odttf files is the same font type?

A: 

I guess we can't do this.

Anwar Chandra
A: 

Sometimes (but not always) it is possible to figure out the font name by looking at the final part of the odttf file. In fact, I am routinely extracting font names from odttf files (generated by the XPS Document Writer) with a python script by looking at what immediately precedes and follows the phrase "This is a unique ID" that can be found in the last 100 or so bytes of every odttf file that I have seen so far. Of course, this is a terrible hack - but it works (for me, at least).

Whether this really works seems to depend on what program generated the PDF file and/or what program is used to print the PDF file to the XPS Document Writer and/or what specific fonts the PDF document contains.

My experience is mostly limited to converting PDFs generated by pdflatex in this way: as an online math tutor I need to convert formulas, text and drawings from PDF to XAML in order to be able to paste them into a shared whiteboard that is based on WPF. So this hack might or might not work for you. (Also: this hack might stop working any time...)

Instead of trying to figure out the font name you could also convert your PDFs to XAML by eliminating the font references entirely: You can crop the PDF with pdfcrop (by Heiko Oberdiek) before sending it to the XPS Document Writer. In my experience this forces the combination of Adobe Reader and XPS Document Writer (for reasons unknown to me) to produce XAML code that does not contain any Glyphs, and thus no references to fonts (contained in obfuscated odttf files). But, unfortunately, you get much more XAML code, because all glyphs have to be represented by paths (which involves a great deal of repetition).

Regards, Christian

Christian Stapfer