• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Guest
Oct 29, 2013 Oct 29, 2013

Copy link to clipboard

Copied

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

TOPICS
Programming

Views

3.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

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? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

I reviewed the code above.  But it does not appear to have anything about "Subject" and "Keywords".  Plus, as you mentioned, this code looks like it is for the PDF file.  I as mentioned, I do not want to edit the PDF file.  I am already editing the .PS file for other reasons.  So while I am editing the .PS file, I would like to add entries which will create the "Subject" and "Keywords" properties in the PDF when I convert the .ps to PDF. 

Can this be done? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

The code is PostScript. You could adapt it to do more metadata, or set it more simply by just calling pdfmark directly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 01, 2013 Nov 01, 2013

Copy link to clipboard

Copied

Thanks for replying, but I am not sure that my question is getting answered.  I guess I am not explaining myself clearly.  I am not a PostScript guru, nor do I want to be.  I just want to edit my PostScript files hopefully by adding some simple lines into the .ps, so that when I process the PS to PDF the "Subject" and "Keywords" properties are entered in the resulting PDF file. 

Here is an example of getting the "Author" field populated in the PDF file, by editing the PS file.  I know that if I add this line into the PS file -

%%For: JohnB

then resulting PDF file will have "JohnB" in its "Author" field.  So whenever I want the "Author" field populated in the PDF file, I simply add this line above and where "JohnB" field is, I enter whatever I want to be the Author.  The %%For line in the PS file results in the "Author" field populated in the PDF file.  I already do this and know it works. 

This %%For line is a single line, and it did not require extensive PostScript knowledge.  So it would appear to me that there probably is similar simple lines or entries that can be added into the PS file, for both the "Subject" and "Keywords" properties to be set in the PDF file, once converted.  I do not expect that it takes several lines, as this was not necessary for the %%For edit. 

So, is there a similar line or entry I can add into the PS file that will yield the "Subject" and "Keywords" properties in the PDF file? 

If so, please post this line or lines, or give an example. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2013 Nov 01, 2013

Copy link to clipboard

Copied

%%For is a special comment with a special meaning, picked up by Distiller (if the options are set). I don't know if there are special comments for subject and keywords; probably not, as these comments were set in stone before PDF was invented.

Assuming that there are not, you need to add pdfmark instructions. You may not want to learn how to do this, but it is how it is done. The lines will be simple, but not %% lines. I will not write them for you, sorry. The PDFMark Reference is the document you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 01, 2013 Nov 01, 2013

Copy link to clipboard

Copied

I am not convinced that PDF properties "Subject" and "Keywords" cannot be entered in the PS file like other PDF properties (%%Creator:, %%Title:,

%%CreationDate:, %%For:, etc.).  But you said that if using PDFMark, the lines will be simple.  So I am curious, and want to be clear -

Are these PDFMark lines added to the PS file or the PDF file? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2013 Nov 01, 2013

Copy link to clipboard

Copied

LATEST

You are welcome to be not convinced. I certainly haven't checked.

A PostScript file is a program written in the programming language PostScript.

If you modify PostScript files you are a PostScript programmer, like it or not.

pdfmark (all lower case) is part of the PostScript language understood by Distiller (but rejected by printers).

pdfmark is used by Distiller to add things to a PDF which have no direct PostScript equivalent - like metadata (a fancy name for what you want).

So, yes, added to the PS file. You could not add things to a PDF file with a text editor, they aren't that kind of thing (though they look superficially like it).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines