Ghostscript need native PDF graphic state. Currently. conversion from PDF file with "2 Tr" (fill and stroke) to another PDF expands all text into lines and curves. There's no way to reproduce Acrobat results (bug 688007) without passing "2 Tr" from PS level to PDF level.
Created attachment 1619 [details] tr.tar.gz A simple PDF file with "2 Tr" and the result of PDF to PDF conversion.
Assigning to Ray for comment. Igor would like feedback on what the best resolution of this (if any) would be. Please follow up, and then close or assign to Igor.
Hmm, I can see another possible problem. The PDF 1.3 specification reads on page 162 : "In PDF (unlike PostScript),the current path is not part of the graphics state and is not saved and restored along with the other graphics state parameters.".
The problem with "2 Tr" actually doesn't require a "native PDF graphic state". A conversion of a text into outlines happens due to the implementation of text operators is made with charpath for some text rendering modes. A better way is to build a copy of the current font with replacing PaintType, and then 'show' the text twice - with the original font, and with the "stroking" font. Alex, IMO you can make a local patch to pdf_ops.ps, but please first comply with Ray about the terms|bounty.
A correction to Comment#3 : I've meant the PDF reference 1.4 .
In fact, the pass-through handling of the text rendering mode is already implemented in the PostScript part of th PDF interpreter (rev. 7794) However, the following code in gdevpdtt.c quashes non-default rendering modes in most cases. ppts->values.render_mode = (penum->pis->text_rendering_mode == 3 ? 3 : font->PaintType == 0 ? 0 : penum->pis->text_rendering_mode); Should it be replaced with : ppts->values.render_mode = penum->pis->text_rendering_mode;
Passing to Ken since he handles pdfwrite from now. Likely this bug doesn't need any fix to modern code and to be closed as worksforme, but please check for sure.
There is a problem of some sort here, and I believe its due to the Tr not being preserved. While the original job does work now, I modified it to use different stroke and fill colours (unlike the original). The PDF resulting from pdfwrite doesnot contain a Tr, and renders the text all in black, where my modified file renders a stroked outline in red. I believe this does need work, and I do think that the text rendering state does need to be preserved. FWIW, the output file also doesn't contain the correct (modified) stroke colour either. I do believe this is a bug, not an enhancement, the file does (now at least) display incorrectly after conversion.
Bug still reproducible in Ghostscript 9.03
I believe this is finally fixed in git commit: 419d3f8f787d90a71623b27100972eca64d03cc1