Bug 103944 - Feature request: allow pdftocairo to embed fonts when performing PDF to PS conversion
Summary: Feature request: allow pdftocairo to embed fonts when performing PDF to PS co...
Status: RESOLVED WORKSFORME
Alias: None
Product: poppler
Classification: Unclassified
Component: cairo backend (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-27 22:21 UTC by Alex Korobkin
Modified: 2017-11-29 14:35 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
f.pdf (54.24 KB, application/pdf)
2017-11-28 15:10 UTC, Alex Korobkin
Details
f-cairo.ps (129.35 KB, application/postscript)
2017-11-28 15:11 UTC, Alex Korobkin
Details
f-pdftops.ps (114.64 KB, application/postscript)
2017-11-28 15:11 UTC, Alex Korobkin
Details

Description Alex Korobkin 2017-11-27 22:21:58 UTC
I'm using wonderful pdftocairo on my printserver for PDF to PS level3 conversion, and from time to time I stumble upon PDFs that come with non-embedded Type 1 fonts. 

$ pdffonts my.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
Helvetica                            Type 1            WinAnsi          no  no  no      17  0
Helvetica-Bold                       Type 1            WinAnsi          no  no  no      18  0

pdftops embeds fonts on the fly, but has an option to pass font data as is. pdftocairo doesn't embed fonts into PS, and doesn't have any relevant options. I know can manually do something like 
pdftocairo -pdf my.pdf - | pdftocairo -ps -level3 - result.ps
and it will embed fonts, but that means custom filters for the CUPS server, and double processing for the file. 

Could pdftocairo please have an option to embed fonts if asked to? It seems to be capable of doing it, but doesn't have a way for PDF to PS conversion. 

Thanks!
Comment 1 Adrian Johnson 2017-11-28 08:25:37 UTC
I'm not sure what problem you are seeing. Cairo always embeds fonts in PDF and PS output. You should be able to see the embedded fonts with

grep ^%%BeginResource <ps-file>

The only way you would not get every font embedded is if the text has been replaced with a fallbacl image. You can check for fallback images with:

grep '^% Fallback Image' <ps-file>
Comment 2 Alex Korobkin 2017-11-28 15:10:29 UTC
Created attachment 135769 [details]
f.pdf
Comment 3 Alex Korobkin 2017-11-28 15:11:00 UTC
Created attachment 135770 [details]
f-cairo.ps
Comment 4 Alex Korobkin 2017-11-28 15:11:16 UTC
Created attachment 135771 [details]
f-pdftops.ps
Comment 5 Alex Korobkin 2017-11-28 15:12:11 UTC
Sorry, my PostScript knowledge is close to zero, I thought it was because of the fonts. I appreciate the explanation, thank you.

Maybe we're looking at a bug then. Here is the original pdf: f.pdf

Also two PS files produced by
pdftocairo -ps -level3 f.pdf f-cairo.ps
and
pdftops -ps -level3 f.pdf f-pdftops.ps

pdftops version prints perfectly, no issues. 
pdftocairo version is rejected by the printer, it says 

%%[ Error: undefined; OffendingCommand: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ]%%
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

Why would the printer be unhappy about the cairo version, is there anything wrong in that PS file?
Comment 6 Adrian Johnson 2017-11-28 20:11:47 UTC
I can reproduce the issue on my printer with your f-cairo.ps file. I also tried converting f.ps to ps using current cairo git and it worked. I don't know is wrong with the 1.14.10 version but it seems to be fixed now.

Try it with cairo git and see if it works for you.
Comment 7 Adrian Johnson 2017-11-29 08:12:56 UTC
(In reply to Alex Korobkin from comment #5)
> %%[ Error: undefined; OffendingCommand:
> zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ]%%
> %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

The zzzz is in the image data. It is data leftover after the image has been read and the PS parser chokes on it. There is already a fix for that in cairo 1.14.10:

https://cgit.freedesktop.org/cairo/commit/?h=1.14&id=0aafba93f796758aebb2f8c3b4585b049dc0c30c

I built 1.14.10 and confirmed the PS output prints correctly. I'm not sure why you have cairo output that contains the '1.14.10' version but does not contain this fix. Your output is missing the 'cairo_flush_ascii85_file' stuff in the PS Prolog so your version does not contain this fix.
Comment 8 Alex Korobkin 2017-11-29 14:35:20 UTC
Thank you! I tested with 1.15.8, it certainly works now.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.