Package org.mapfish.print
Class MapPrinter
- java.lang.Object
-
- org.mapfish.print.MapPrinter
-
public class MapPrinter extends java.lang.Object
The main class for printing maps. Will parse the spec, create the PDF document and generate it.This class should not be directly created but rather obtained from an application context object so that all plugins and dependencies are correctly injected into it
-
-
Constructor Summary
Constructors Constructor Description MapPrinter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Configuration
getConfiguration()
OutputFormat
getOutputFormat(PJsonObject specJson)
Get the object responsible for printing to the correct output format.java.util.Set<java.lang.String>
getOutputFormatsNames()
Return the available format ids.static PJsonObject
parseSpec(java.lang.String spec)
Parse the JSON string and return the object.Processor.ExecutionContext
print(java.util.Map<java.lang.String,java.lang.String> mdcContext, PJsonObject specJson, java.io.OutputStream out)
Start a print.void
printClientConfig(org.json.JSONWriter json)
Use by /info.json to generate its returned content.void
setConfiguration(java.io.File newConfigFile)
Set the configuration file and update the configuration for this printer.void
setConfiguration(java.net.URI newConfigFile, byte[] configFileData)
Set the configuration file and update the configuration for this printer.
-
-
-
Method Detail
-
parseSpec
public static PJsonObject parseSpec(java.lang.String spec)
Parse the JSON string and return the object. The string is expected to be the JSON print data from the client.- Parameters:
spec
- the JSON formatted string.- Returns:
- The encapsulated JSON object
-
setConfiguration
public final void setConfiguration(java.net.URI newConfigFile, byte[] configFileData) throws java.io.IOException
Set the configuration file and update the configuration for this printer.- Parameters:
newConfigFile
- the file containing the new configuration.configFileData
- the config file data.- Throws:
java.io.IOException
-
getConfiguration
public final Configuration getConfiguration()
-
setConfiguration
public final void setConfiguration(java.io.File newConfigFile) throws java.io.IOException
Set the configuration file and update the configuration for this printer.- Parameters:
newConfigFile
- the file containing the new configuration.- Throws:
java.io.IOException
-
printClientConfig
public final void printClientConfig(org.json.JSONWriter json) throws org.json.JSONException
Use by /info.json to generate its returned content.- Parameters:
json
- the writer for outputting the config specification- Throws:
org.json.JSONException
-
getOutputFormat
public final OutputFormat getOutputFormat(PJsonObject specJson)
Get the object responsible for printing to the correct output format.- Parameters:
specJson
- the request json from the client
-
print
public final Processor.ExecutionContext print(@Nonnull java.util.Map<java.lang.String,java.lang.String> mdcContext, PJsonObject specJson, java.io.OutputStream out) throws java.lang.Exception
Start a print.- Parameters:
mdcContext
- the MDC context for the current print job.specJson
- the client json request.out
- the stream to write to.- Throws:
java.lang.Exception
-
getOutputFormatsNames
public final java.util.Set<java.lang.String> getOutputFormatsNames()
Return the available format ids.
-
-