Bug 693400

Summary: PDF metadata not correctly written to output file
Product: Ghostscript Reporter: Marco <netuse>
Component: PDF WriterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P4    
Version: master   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: Test file

Description Marco 2012-10-22 07:15:44 UTC
Created attachment 9015 [details]
Test file

The PDF metadata for `title` and `creator` is not correctly written to the output file. Under certain conditions different values appear in the output file compared to the input file. This does not occur for every PDF, the metadata of some PDF files is transferred correctly. I don't know which property of the PDF makes this difference. A test file is attached.

Here are the steps to reproduce.

<pre>
$ pdfinfo input.pdf
  Title:          AAA
  Subject:        BBB
  Keywords:       CCC
  Author:         DDD
  Creator:        ConTeXt - 2012.10.20 11:51
  Producer:       LuaTeX-0.70.2
  CreationDate:   Sun Oct 21 19:10:21 2012
  ModDate:        Sun Oct 21 19:10:21 2012
  Tagged:         no
  Pages:          1
  Encrypted:      no
  Page size:      595.276 x 841.89 pts (A4)
  File size:      87171 bytes
  Optimized:      no
  PDF version:    1.6

  $ gs -sDEVICE=pdfwrite -o output.pdf input.pdf
  GPL Ghostscript GIT PRERELEASE 9.07 (2012-07-31)
  Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
  This software comes with NO WARRANTY: see the file PUBLIC for details.
  Processing pages 1 through 1.
  Page 1

  $ pdfinfo output.pdf
  Title:          NimbusSanL-Regu
  Subject:        BBB
  Keywords:       CCC
  Author:         DDD
  Creator:        frob
  Producer:       GPL Ghostscript GIT PRERELEASE 9.07
  CreationDate:   Sun Oct 21 19:22:14 2012
  ModDate:        Sun Oct 21 19:22:14 2012
  Tagged:         no
  Pages:          1
  Encrypted:      no
  Page size:      595.276 x 841.89 pts (A4)
  File size:      10043 bytes
  Optimized:      no
  PDF version:    1.4
</pre>
Comment 1 Ken Sharp 2012-10-23 10:46:45 UTC
The PDF file in question contains a type 1 font stream for NimbusSanL-Regular, the font stream uses DSC (Document Structure Convention) comments, which are inappropriate for a font (in particular the %%Title: comment makes no real sense).

The Creator and Title you are seeing are embedded in the type 1 font, and are overriding the same information supplied from the original PDF file.

The Distiller documentation says that Distiller processes DSC comments, but gives no details, therefore by default the pdfwrite device also processes DSC comments.  Because the font contains inappropriate DSC comments there isn't really anything we can do about this except prevent DSC processing.

If you set the flag -dProcessDSCComments=false you should find that the problem goes away.
Comment 2 Marco 2012-10-23 12:09:33 UTC
(In reply to comment #1)
> The PDF file in question contains a type 1 font stream for NimbusSanL-Regular,
> the font stream uses DSC (Document Structure Convention) comments, which are
> inappropriate for a font (in particular the %%Title: comment makes no real
> sense).
> 
> The Creator and Title you are seeing are embedded in the type 1 font, and are
> overriding the same information supplied from the original PDF file.

Thanks for checking this. The included graphs with the %%Title comments are being provided, I don't have any influence on that. However, I will send a bug report that the developers are aware of the issue. It's a bug in the NimbusSans font, not in the application which created the PDF (LibreOffice Draw), right?

> If you set the flag -dProcessDSCComments=false you should find that the problem
> goes away.

That fixed it, the title and creator are correct now.
Comment 3 Ken Sharp 2012-10-23 12:14:45 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > The PDF file in question contains a type 1 font stream for NimbusSanL-Regular,
> > the font stream uses DSC (Document Structure Convention) comments, which are
> > inappropriate for a font (in particular the %%Title: comment makes no real
> > sense).
> > 
> > The Creator and Title you are seeing are embedded in the type 1 font, and are
> > overriding the same information supplied from the original PDF file.
> 
> Thanks for checking this. The included graphs with the %%Title comments are
> being provided, I don't have any influence on that. However, I will send a bug
> report that the developers are aware of the issue. It's a bug in the NimbusSans
> font, not in the application which created the PDF (LibreOffice Draw), right?

Its hard to characterise as a bug as such. I personally wouldn't use DSC comments in a font program, for precisely this reason. But its the font, not the application that's at fault (though the application has created the file in a bizarre and rather Cairo-like fashion.