Skip to main content
October 29, 2013
Question

When editing a postscript file, how can I add Document Properties "Subject" and "Keywords"?

  • October 29, 2013
  • 1 reply
  • 3719 views

Hi:

I am editing a postscript file.  I add some data to the .ps file so when the file is converted to a PDF file, some of the PDF's Document Properties are entered, and other variables are set. 

I can get the PDF Document Property "Author" in my resulting PDF file by adding this line to the .ps file - 

%%For: JohnB

When this line is added, and I convert the .ps file, the resulting PDF file has "JohnB" in its "Author" field. 

Now, I would like to edit my .ps file to have the PDF Document Properties "Subject" and "Keywords" added into the PDF file. 

I tried simply adding to the .ps file -

%%Subject: Birds

But this does not work. 

So what do I need to enter into the .ps file to give me the Document Properties "Subject" and "Keywords" in my PDF file? 

Thanks,

Kevin

This topic has been closed for replies.

1 reply

Participating Frequently
October 30, 2013

Try this:

%!

<<

/ProcessDSCComment {

  (%%Title:) anchorsearch {

    pop                         % Discard matching string

    [ /Title                    % set up pdfmark

    3 -1 roll /DOCINFO pdfmark

  }{

    (%%Creator:) anchorsearch {

    pop                         % discard matching string

    [ /Author                   % set up pdfmark

    3 -1 roll /DOCINFO pdfmark

    } {

      (Unrecognised DSC comment ) print print (\n) print

    } ifelse

  } ifelse

pop                             % Discard file arg

}

/ProcessComment {

pop                             % Discard comment

pop                             % Discard the file arg

}

>> setuserparams

%!PS-Adobe-2.0

%%Pages: 1

%%Title: PutTitleHere

%%Creator: PutCreatorHere

%EndComments

October 31, 2013

Your answer appears to only add "Title" and "Creator" into the .ps file.  But I already know how to add those in my postscript file.  As I mentioned, I need to edit the .ps file with entries to give me the Document Properties "Subject" and "Keywords" in the resulting PDF file. 

What can I enter into my postscript file to yield the "Subject" and "Keywords"  Document Properties in the resulting PDF file? 

Legend
October 31, 2013

That code looks as if it is supposed to set the properties in the PDF by using the pdfmark operator. Did you examine it in detail?