Handling Included Files in PostScript Documents
PostScript is a powerful page description language that enables the creation of complex documents with vector graphics, text, and images. Included files are a crucial part of PostScript documents, as they allow for the modularization of code and the reuse of resources. This article will cover the conventions for handling included files in PostScript documents, focusing on DSC comments and the run command.
DSC Comments and Included Files
DSC (Document Structuring Conventions) comments are a set of guidelines for organizing and structuring PostScript code. They provide a standard way to include metadata and information about the document, making it easier to understand and maintain. When working with included files, DSC comments can help keep track of the relationships between files and ensure that they are used correctly.
An included file in a PostScript document is typically specified using the %include directive. This directive tells the PostScript interpreter to read and execute the contents of the specified file. For example:
%include "myfile.ps"To include DSC comments in an included file, you can use the %%DocumentData and %%DocumentStructurersEntries comments. These comments provide information about the document structure and can help ensure that the included file is used correctly.
%%DocumentData: Clean7Bit
%%DocumentStructurersEntries: Prolog, Executive, Body, Postamble
Running Included Files with the run Command
Once an included file has been specified using the %include directive, you can run its contents using the run command. The run command executes the contents of the specified file as if they were part of the main document. For example:
(myfile.ps) run
It is important to note that the run command does not automatically include the DSC comments from the included file in the main document. To include the DSC comments, you can use the %include directive instead of the run command. However, if you only need to execute the code in the included file, the run command is a more efficient option.
Best Practices for Handling Included Files
When working with included files in PostScript documents, it is important to follow best practices to ensure that the code is organized, maintainable, and easy to understand. Some best practices include:
- Use descriptive names for included files to make it clear what they contain and how they are used.
- Include DSC comments in both the main document and the included files to provide context and structure.
- Use the %include directive to include DSC comments and metadata from the included files in the main document.
- Use the run command to execute the code in the included files if DSC comments are not needed.
- Keep the code in the included files modular and self-contained to make it easier to reuse and maintain.
References
- Adobe Systems Incorporated. (1990). PostScript Language Reference Manual, Third Edition. Addison-Wesley.
- Ghosh, T. (2002). Advanced PostScript: The Language, Techniques, and Applications. O'Reilly Media.
- Plauger, P. J. (1990). The Standard PostScript Language: A Programmer's Guide and Reference. Addison-Wesley.