Solved

PDF-XChange Viewer Command Line for File -> Export -> Export as Image

Posted on 2016-07-25
2
215 Views
Last Modified: 2016-07-28
Is there a command line for PDF-XChange viewer to automate the process for saving a PDF as a image file through:
File -> Export -> Export as Image
0
Comment
Question by:maverick0728
2 Comments
 
LVL 51

Assisted Solution

by:Joe Winograd, EE MVE
Joe Winograd, EE MVE earned 250 total points
Comment Utility
A couple of comments. First, PDF-XChange Viewer has been discontinued, as stated at Tracker Software's website:
http://www.tracker-software.com/product/pdf-xchange-viewer

My recommendation is to upgrade to PDF-XChange Editor:
http://www.tracker-software.com/product/pdf-xchange-editor

It also has a free version that you may select during installation:

PDF-XChange Editor - Free or Pro
The manual for it is here:
https://www.tracker-software.com/downloads/PDFXE6MAN.zip

Its command line feature has the ability to run JavaScript (the /runjs command, documented on page 31 of the manual). It should be possible to write a JavaScript that does the export, although I haven't done it.

My second comment is a question: Does it have to be done via PDF-XChange? If you're willing to consider other (free!) products, many have a command line option to convert from PDF to image files, including GraphicsMagick, ImageMagick, and IrfanView. This EE article explains how to do it with GraphicsMagick:
Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF

Before reading that, read this other EE article that shows where to get the free GM download and explains the options with respect to its various editions. Regards, Joe
0
 
LVL 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
Looking at https:28959327, it seems you want to convert single-page pdf documents to pictures?
Here's a bit of Powershell that converts using GhostScript: http://www.ghostscript.com/
You can experiment with the different devices; note that the tiffg... devices are fax format and support multiple pages. The other formats only support one page as it is.
Here's the help for the devices: http://www.ghostscript.com/doc/current/Devices.htm
By default, the script will put the new image in the same folder as the pdf, with the respective extension. You can use the Destination argument to save them in a different folder (this expects a folder name, not a file name).
Existing pictures with the same name will be overwritten without warning.
Save as ConvertTo-Image.ps1 or Whatever.ps1.
You can pipe it a batch of documents to convert; example:
Get-ChildItem C:\Temp\*.pdf | .\ConvertTo-Image.ps1 -tiffg4 -Resolution 600

Open in new window

Or save in a different folder:
Get-ChildItem C:\Temp\*.pdf | .\ConvertTo-Image.ps1 -tiffg4 -Resolution 600 -Destination C:\Temp\tiff

Open in new window

[CmdletBinding()]
Param(
	[Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, Position=0)]
	[String[]]$Path,
	[String]$Destination,	## Folder
	[String]$GhostScript = 'C:\Program Files\gs\gs9.19\bin\gswin64c.exe',
	[ValidateSet(
		'bmp16', 'bmp16m', 'bmp256', 'bmp32b', 'bmpgray', 'bmpmono',
		'jpeg', 'jpeggray',
		'png16', 'png16m', 'png256', 'pngalpha', 'pnggray', 'pngmono', 'pngmonod',
		'tiff12nc', 'tiff24nc', 'tiff32nc', 'tiff48nc', 'tiff64nc', 
		'tiffcrle', 'tiffg3', 'tiffg32d', 'tiffg4', 'tiffgray', 'tifflzw', 'tiffpack'
	)]
	[string]$Device = 'tiffg4',
	[uint16]$Resolution = 300,
	[Switch]$PassThru
)
Begin {
	Switch ($Device) {
		{$_.StartsWith('bmp')}	{$NewExtension = '.bmp'}
		{$_.StartsWith('jpeg')}	{$NewExtension = '.jpg'}
		{$_.StartsWith('png')}	{$NewExtension = '.png'}
		{$_.StartsWith('tiff')}	{$NewExtension = '.tiff'}
	}
}
Process {
	$Path |	ForEach-Object {
		If ($FileItem = Get-Item -Path $_) {
			If ($Destination) {
				$OutputFile = Join-Path -Path $Destination -ChildPath ($FileItem.BaseName + $NewExtension)
			} Else {
				$OutputFile = $FileItem.FullName -replace "$([regex]::Escape($FileItem.Extension))\Z", $NewExtension
			}
			& $GhostScript -dNOPAUSE -dBATCH -sDEVICE="$($Device)" -r"$($Resolution)" -sOutputFile="$($OutputFile)" $FileItem.FullName -q 2>&1 | Write-Host -ForegroundColor Gray
			If ($PassThru -and ($LASTEXITCODE -eq 0)) {
				Get-Item -Path $OutputFile
			}
		}
	}
}
End {
}

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
This video Micro Tutorial is the second in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now