WP_Image_Editor_Imagick::pdf_setup() WordPress Method

The WP_Image_Editor_Imagick::pdf_setup() method is used to setup the Imagick PDF library for use with Wordpress. This includes setting up the environment variables and loading the library.

WP_Image_Editor_Imagick::pdf_setup() #

Sets up Imagick for PDF processing.


Description

Increases rendering DPI and only loads first page.


Top ↑

Return

(string|WP_Error) File to load or WP_Error on failure.


Top ↑

Source

File: wp-includes/class-wp-image-editor-imagick.php

	protected function pdf_setup() {
		try {
			// By default, PDFs are rendered in a very low resolution.
			// We want the thumbnail to be readable, so increase the rendering DPI.
			$this->image->setResolution( 128, 128 );

			// Only load the first page.
			return $this->file . '[0]';
		} catch ( Exception $e ) {
			return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.