---
name: "ppd_emit_to_file"
section: "3"
platform: "linux"
package: "libppd-dev"
version: "2:0.10-9"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/ppd_emit_to_file"
---

# ppd\_emit\_to\_file(3)

Output device specific code.

## NAME

ppd\_emit\_to\_file, ppd\_emit\_to\_fd - Output device specific code.

## SYNOPSIS

```
#include <ppd/ppd.h>

gboolean ppd_emit( PpdFile * ppd,FILE *fp,PpdSectionOrder section );
gboolean ppd_emitfd( PpdFile * ppd, int fd,PpdSectionOrder section );
```

## DESCRIPTION

The **ppd\_emit\_\*** functions output the device specific code appropriate to the specified section that has not already been emitted.. The PpdFile pointer is obtained from opening a PPD file via the ppd\_load(3) family of functions.  The section can be any one of the following:

- **PPD\_ORDER\_ANY**

  Option code can be anywhere in the file

- **PPD\_ORDER\_DOCUMENT**

  Option code must be in the DocumentSetup section

- **PPD\_ORDER\_EXIT**

  Option code must be sent prior to the document

- **PPD\_ORDER\_JCL**

  Option code must be sent as a JCL command

- **PPD\_ORDER\_PAGE**

  Option code must be in the PageSetup section

- **PPD\_ORDER\_PROLOG**

  Option code must be in the Prolog section

The sections **PPD\_ORDER\_DOCUMENT** and **PPD\_ORDER\_PAGE** will also output code from the **PPD\_ORDER\_ANY** section.

Once a code section has been emitted it is marked as such and will not be emitted unless it is re-marked.

## EXAMPLE

```
	/* Setup code to emitted */
        ppd_mark_defaults(ppd);
        ppd_mark_option(ppd,"Duplex","DuplexNoTumble");
        ppd_mark_option(ppd,"PageSize","A4");
	/* Emit initial code (including any reset and JCL code) */
        ppd_emit_to_file(ppd,stdout,PPD_ORDER_EXIT);
        fputs(ppd->jcl_begin->str,stdout);
        ppd_emit_to_file(ppd, stdout, PPD_ORDER_JCL);
        fputs(ppd->jcl_ps->str, stdout);
	/* Any header comments go here */
	...
	/* Prolog section */
        printf("%%%%BeginProlog0);
        ppd_emit_to_file(ppd, stdout, PPD_ORDER_PROLOG);
        printf("%%%%EndProlog0);
	/* Setup section */
        printf("%%%%BeginSetup0);
        ppd_emit_to_file(ppd, stdout, PPD_ORDER_DOCUMENT);
        printf("%%%%EndSetup0);
	/* Main document begins */
	for (...) {
		printf("%%%%Page: 1 10);
		/* Re-mark so that this is emitted on each page */
        	ppd_mark_option(ppd,"PageSize","A4");
        	printf("%%%%PageSetup0);
        	ppd_emit_to_file(ppd, stdout, PPD_ORDER_PAGE);
        	printf("%%%%EndPageSetup0);
		/* Page info goes here */
		...
	}
	/* Send ending JCL code */
        fputs(ppd->jcl_end->str,stdout);
```

## SEE ALSO

[**ppd\_file\_new**(3)](/ppd_file_new/3.md), [**ppd\_file\_free**(3)](/ppd_file_free/3.md)
