<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>122147</bug_id>
          
          <creation_ts>2006-02-17 11:15:10 +0000</creation_ts>
          <short_desc>insert &apos;%%Title: xyz&apos; (PostScript DSC comment) into printjob so that KJobViewer displays job name (instead using generic dummy name)</short_desc>
          <delta_ts>2007-01-12 20:25:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>Unmaintained</classification>
          <product>kpdf</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="S. Burmeister">sven.burmeister</reporter>
          <assigned_to name="Albert Astals Cid">aacid</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>414857</commentid>
    <comment_count>0</comment_count>
    <who name="S. Burmeister">sven.burmeister</who>
    <bug_when>2006-02-17 11:15:11 +0000</bug_when>
    <thetext>Version:           0.1 (using KDE 3.5.1 Level &quot;a&quot; , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15.8-default

Currently, when I print a document from kpdf for example, the column &quot;name&quot; only contains &quot;KDE Print System&quot;. I did not find any possibility to display the document&apos;s name of a printjob.

Without the document&apos;s name, it is hardly possible to distinguish between several printjobs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500539</commentid>
    <comment_count>1</comment_count>
    <who name="Kurt Pfeifle">pfeifle</who>
    <bug_when>2007-01-11 14:20:36 +0000</bug_when>
    <thetext>Confirmed.

This is a deficiency. However, I don&apos;t think it is KDEPrint&apos;s/KJobViewer&apos;s realm.

AFAIK, KJobViewer is designed to display the CUPS &quot;job title&quot; that it gets handed over by the application. Only if it doesn&apos;t get such an info, it will fill in the  &quot;KDE Print System&quot; string as the job title (because CUPS requires one).

I&apos;ll move that bug to the kpdf module for now.

But similar deficiencies probably affect other (KDE) applications as well... I just don&apos;t have the time right now to check them all. (KWord for example, does The Right Thing (TM) here...)


@ kpdf developers:
------------------

kpdf should insert a &quot;%%Title: whatever-it-should-be&quot; line in the PostScript DSC comments near the top of the printfile. But this line is completely missing.

See how KWord does it:

  * if the &quot;Title:&quot; line is filled in by the user (menu &quot;File --&gt; Document 
    Information --&gt; General&quot;) KWord inserts that string as %%Title:

  * if the &quot;Title:&quot; line is empty, KWord simply takes the the document&apos;s file
    name and places that into the PostScript jobfile as %%Title:

I think kpdf should do the same. (Maybe even on the level of Poppler -- you know better than me...)

(BTW, the %%Title: line of a PostScript file is also evaluated by allmost all PostScript printers to display the job name on their front panel displays, or to show it in SNMP queries.)

Cheers,
Kurt

(changed $summary, previous one was: &quot;wish: show name of document in printjob&quot;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500542</commentid>
    <comment_count>2</comment_count>
    <who name="Kurt Pfeifle">pfeifle</who>
    <bug_when>2007-01-11 14:27:48 +0000</bug_when>
    <thetext>slightly off-topic:

Note, that KWord could improve as well: in case a user creates a new document and prints it without having saved it to a file, the %%Title line is missing in their PostScript as well.

To help the user identify such jobs, KWord should probably insert something like

  %%Title: KWord unsaved doc ($current_date)

instead. Otherwise the users sees only the KDEPrint-inserted dummy &quot;KDE Print System&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500663</commentid>
    <comment_count>3</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2007-01-11 21:05:29 +0000</bug_when>
    <thetext>Now the question is, which should the title be?
filename, complete file path, the name reported by the pdf file?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500666</commentid>
    <comment_count>4</comment_count>
    <who name="Pino Toscano">pino</who>
    <bug_when>2007-01-11 21:10:03 +0000</bug_when>
    <thetext>What about document title, or file name if the document has no title?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500686</commentid>
    <comment_count>5</comment_count>
    <who name="Kurt Pfeifle">pfeifle</who>
    <bug_when>2007-01-11 22:19:24 +0000</bug_when>
    <thetext>

Heh... David fixed my wishlist bug 139905 for KWord within 12 minutes  :-)

I am aware that for kpdf the PostScript is not generated by Qt, but by poppler/xpdf, so surely you need a completely different solution... but just in case you want to look, his patch is to be found at bug 139905.

I now also found that even documents where the PDF meta data for Title: are filled in correctly, the commandline pdftops from xpdf does not write a %%Title into the output PS file.

To me, that looks like a clear bug in xpdf too. So you&apos;ve probably inherited that in Poppler as well....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500690</commentid>
    <comment_count>6</comment_count>
    <who name="Kurt Pfeifle">pfeifle</who>
    <bug_when>2007-01-11 22:24:54 +0000</bug_when>
    <thetext>@ comment 3 (Albert):

My suggestion (and I *believe* that&apos;s how Acrobat handles it too, but can&apos;t verify right now), in the order of preference:

 * if the PDF has a meta data a &apos;Title:&apos; field that&apos;s not empty: use this.
 * if the metadata &apos;Title&apos; is empty, use the filename.
 
Don&apos;t use the path *at* *all*. It may leak to much (private and security sensitive) info which the user for sure would not like.

Cheers,
and thanks for the quick reaction :-)

Kurt</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>500921</commentid>
    <comment_count>7</comment_count>
    <who name="Pino Toscano">pino</who>
    <bug_when>2007-01-12 20:25:05 +0000</bug_when>
    <thetext>SVN commit 622742 by pino:

When generating a Postscript document, output the %%Title for the PS document this way:
- the document title, if it has one, or
- the file name of the document (eg foo.pdf for /home/me/foo.pdf)

BUGS: 122147


 M  +3 -1      core/generator.h  
 M  +11 -5     core/generator_pdf/generator_pdf.cpp  
 M  +1 -1      core/generator_pdf/generator_pdf.h  
 M  +13 -7     xpdf/xpdf/PSOutputDev.cc  
 M  +3 -3      xpdf/xpdf/PSOutputDev.h  


--- branches/KDE/3.5/kdegraphics/kpdf/core/generator.h #622741:622742
@@ -80,9 +80,11 @@
         /** constructor: takes the Document as a parameter **/
         Generator( KPDFDocument * doc ) : m_document( doc ) {};
 
+    protected:
+        KPDFDocument * m_document;
+
     private:
         Generator();
-        KPDFDocument * m_document;
 };
 
 /**
--- branches/KDE/3.5/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp #622741:622742
@@ -440,7 +440,13 @@
     KTempFile tf( QString::null, &quot;.ps&quot; );
     globalParams-&gt;setPSPaperWidth(paperWidth);
     globalParams-&gt;setPSPaperHeight(paperHeight);
-    PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), pdfdoc-&gt;getXRef(), pdfdoc-&gt;getCatalog(), 1, pdfdoc-&gt;getNumPages(), psModePS, marginRight, marginBottom, paperWidth - marginLeft, paperHeight - marginTop);
+    QString pstitle = getDocumentInfo(&quot;Title&quot;, true);
+    if ( pstitle.isEmpty() )
+    {
+        pstitle = m_document-&gt;currentDocument().fileName( false );
+    }
+    const char* pstitlechar = !pstitle.isEmpty() ? pstitle.local8Bit() : 0;
+    PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), pstitlechar, pdfdoc-&gt;getXRef(), pdfdoc-&gt;getCatalog(), 1, pdfdoc-&gt;getNumPages(), psModePS, marginRight, marginBottom, paperWidth - marginLeft, paperHeight - marginTop);
 
     if (psOut-&gt;isOk())
     {
@@ -686,17 +692,17 @@
     (*fonts)[fontsLen++] = *font-&gt;getID();
 }
 
-QString PDFGenerator::getDocumentInfo( const QString &amp; data ) const
+QString PDFGenerator::getDocumentInfo( const QString &amp; data, bool canReturnNull ) const
 // note: MUTEX is LOCKED while calling this
 {
     // [Albert] Code adapted from pdfinfo.cc on xpdf
     Object info;
     if ( !pdfdoc )
-        return i18n( &quot;Unknown&quot; );
+        return canReturnNull ? QString::null : i18n( &quot;Unknown&quot; );
 
     pdfdoc-&gt;getDocInfo( &amp;info );
     if ( !info.isDict() )
-        return i18n( &quot;Unknown&quot; );
+        return canReturnNull ? QString::null : i18n( &quot;Unknown&quot; );
 
     QString result;
     Object obj;
@@ -739,7 +745,7 @@
     }
     obj.free();
     info.free();
-    return i18n( &quot;Unknown&quot; );
+    return canReturnNull ? QString::null : i18n( &quot;Unknown&quot; );
 }
 
 QString PDFGenerator::getDocumentDate( const QString &amp; data ) const
--- branches/KDE/3.5/kdegraphics/kpdf/core/generator_pdf/generator_pdf.h #622741:622742
@@ -92,7 +92,7 @@
         void fillViewportFromLink( DocumentViewport &amp;viewport, LinkDest *destination );
 
         // private functions for accessing document informations via PDFDoc
-        QString getDocumentInfo( const QString &amp; data ) const;
+        QString getDocumentInfo( const QString &amp; data, bool canReturnNull = false ) const;
         QString getDocumentDate( const QString &amp; data ) const;
         // private function for creating the document synopsis hieracy
         void addSynopsisChildren( QDomNode * parent, GList * items );
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PSOutputDev.cc #622741:622742
@@ -887,7 +887,7 @@
   fwrite(data, 1, len, (FILE *)stream);
 }
 
-PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog,
+PSOutputDev::PSOutputDev(const char *fileName, const char *title, XRef *xrefA, Catalog *catalog,
 			 int firstPage, int lastPage, PSOutMode modeA,
 			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
 			 GBool manualCtrlA) {
@@ -938,7 +938,7 @@
     }
   }
 
-  init(outputToFile, f, fileTypeA,
+  init(outputToFile, f, title, fileTypeA,
        xrefA, catalog, firstPage, lastPage, modeA,
        imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
 }
@@ -963,12 +963,12 @@
   haveTextClip = gFalse;
   t3String = NULL;
 
-  init(outputFuncA, outputStreamA, psGeneric,
+  init(outputFuncA, outputStreamA, 0, psGeneric,
        xrefA, catalog, firstPage, lastPage, modeA,
        imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
 }
 
-void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
+void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, const char *title,
 		       PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
 		       int firstPage, int lastPage, PSOutMode modeA,
 		       int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
@@ -1056,10 +1056,10 @@
       writeHeader(firstPage, lastPage,
 		  catalog-&gt;getPage(firstPage)-&gt;getMediaBox(),
 		  catalog-&gt;getPage(firstPage)-&gt;getCropBox(),
-		  catalog-&gt;getPage(firstPage)-&gt;getRotate());
+		  catalog-&gt;getPage(firstPage)-&gt;getRotate(), title);
     } else {
       box = new PDFRectangle(0, 0, 1, 1);
-      writeHeader(firstPage, lastPage, box, box, 0);
+      writeHeader(firstPage, lastPage, box, box, 0, title);
       delete box;
     }
     if (mode != psModeForm) {
@@ -1147,13 +1147,15 @@
 
 void PSOutputDev::writeHeader(int firstPage, int lastPage,
 			      PDFRectangle *mediaBox, PDFRectangle *cropBox,
-			      int pageRotate) {
+			      int pageRotate, const char *title) {
   double x1, y1, x2, y2;
 
   switch (mode) {
   case psModePS:
     writePS(&quot;%!PS-Adobe-3.0\n&quot;);
     writePSFmt(&quot;%%%%Creator: xpdf/pdftops %s\n&quot;, xpdfVersion);
+    if(title)
+      writePSFmt(&quot;%%%%Title: %s\n&quot;, title);
     writePSFmt(&quot;%%%%LanguageLevel: %d\n&quot;,
 	       (level == psLevel1 || level == psLevel1Sep) ? 1 :
 	       (level == psLevel2 || level == psLevel2Sep) ? 2 : 3);
@@ -1174,6 +1176,8 @@
   case psModeEPS:
     writePS(&quot;%!PS-Adobe-3.0 EPSF-3.0\n&quot;);
     writePSFmt(&quot;%%%%Creator: xpdf/pdftops %s\n&quot;, xpdfVersion);
+    if(title)
+      writePSFmt(&quot;%%%%Title: %s\n&quot;, title);
     writePSFmt(&quot;%%%%LanguageLevel: %d\n&quot;,
 	       (level == psLevel1 || level == psLevel1Sep) ? 1 :
 	       (level == psLevel2 || level == psLevel2Sep) ? 2 : 3);
@@ -1208,6 +1212,8 @@
   case psModeForm:
     writePS(&quot;%!PS-Adobe-3.0 Resource-Form\n&quot;);
     writePSFmt(&quot;%%%%Creator: xpdf/pdftops %s\n&quot;, xpdfVersion);
+    if(title)
+      writePSFmt(&quot;%%%%Title: %s\n&quot;, title);
     writePSFmt(&quot;%%%%LanguageLevel: %d\n&quot;,
 	       (level == psLevel1 || level == psLevel1Sep) ? 1 :
 	       (level == psLevel2 || level == psLevel2Sep) ? 2 : 3);
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PSOutputDev.h #622741:622742
@@ -53,7 +53,7 @@
 public:
 
   // Open a PostScript output file, and write the prolog.
-  PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog,
+  PSOutputDev(const char *fileName, const char *title, XRef *xrefA, Catalog *catalog,
 	      int firstPage, int lastPage, PSOutMode modeA,
 	      int imgLLXA = 0, int imgLLYA = 0,
 	      int imgURXA = 0, int imgURYA = 0,
@@ -102,7 +102,7 @@
   // Write the document-level header.
   void writeHeader(int firstPage, int lastPage,
 		   PDFRectangle *mediaBox, PDFRectangle *cropBox,
-		   int pageRotate);
+		   int pageRotate, const char *title);
 
   // Write the Xpdf procset.
   void writeXpdfProcset();
@@ -222,7 +222,7 @@
 
 private:
 
-  void init(PSOutputFunc outputFuncA, void *outputStreamA,
+  void init(PSOutputFunc outputFuncA, void *outputStreamA, const char *title,
 	    PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
 	    int firstPage, int lastPage, PSOutMode modeA,
 	    int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>