GNU Astronomy Utilities


Previous: , Up: File input output   [Contents][Index]


10.3.12.5 PDF files (pdf.h)

The portable document format (PDF) has arguably become the most common format used for distribution of documents. In practice, a PDF file is just a compiled PostScript file. For a more complete introduction, please see Recognized file formats. To provide high quality graphics, the PDF is a vectorized format, therefore pixels (elements of a “rasterized” format) aren’t defined in their context. As a result, similar to EPS files (eps.h), Gnuastro only writes datasets to a PDF file, not vice-versa.

Function:
int
gal_pdf_name_is_pdf (char *name)

Return 1 if name has an PDF suffix. This can be used to make sure that a given input file is PDF. See gal_pdf_suffix_is_pdf for a list of recognized suffixes.

Function:
int
gal_pdf_suffix_is_pdf (char *name)

Return 1 if suffix is a recognized PDF suffix. The recognized suffixes are .pdf and .PDF.

Function:
void
gal_pdf_write (gal_data_t *in, char *filename, float widthincm, uint32_t borderwidth, int dontoptimize)

Write the in dataset into an EPS file called filename. in has to be an unsigned 8-bit character type (GAL_TYPE_UINT8, see Numeric data types). The desired width of the image in human/non-pixel units (to help the displayer) can be set with the widthincm argument. If borderwidth is non-zero, it is interpreted as the width (in points) of a solid black border around the image. A border can helpful when importing the PDF file into a document.

This function is just a wrapper for the gal_eps_write function in EPS files (eps.h). After making the EPS file, Ghostscript (with a version of 9.10 or above, see Optional dependencies) will be used to compile the EPS file to a PDF file. Therefore if GhostScript doesn’t exist, doesn’t have the proper version, or fails for any other reason, the EPS file will remain. It can be used to find the cause, or use another converter or PostScript compiler.

By default, when the dataset only has two values, this function will use the PostScript optimization that allows setting the pixel values per bit, not byte (Recognized file formats). This can greatly help reduce the file size. However, when dontoptimize!=0, this optimization is disabled: even though there are only two values (is binary), the difference between them does not correspond to the full contrast of black and white.


Previous: , Up: File input output   [Contents][Index]