2012-06-12 19 views

Respuesta

11

Dado que Ghostscript es un intérprete PostScript en toda regla, también puede enviarle fragmentos de PostScript que no causen el dibujo de los elementos de la página, pero que lo consultan por su estado interno.

Si desea saber cuáles son los ajustes por defecto del Display son, cuando le pida a través de gs some.pdf simplemente mostrar un PDF en la pantalla, puede probar esto:

gs \ 
    -c "currentpagedevice {exch ==only () print == } forall" 

En Windows esto se convierte :

gswin32c.exe^
    -c "currentpagedevice {exch ==only () print == } forall" 

el resultado es una lista de pares /SomeName somevalue que describen los parámetros utilizados para la prestación de páginas a la pantalla actual.

Esto es así porque normalmente la pantalla es el dispositivo predeterminado para que Ghostscript envíe su salida. Ahora puede observar que verá una ventana vacía de Ghostscript emergente, que tendrá que cerrar ... Ah, ¿qué le parece agregar algunas opciones para evitar la ventana emergente?

gs \ 
    -o /dev/null \ 
    -dNODISPLAY \ 
    -c "currentpagedevice {exch ==only () print == } forall" 

O, en Windows:

gswin32c.exe^
    -o nul^
    -dNODISPLAY^
    -c "currentpagedevice {exch ==only () print == } forall" 

Pero esto va a cambiar los valores de retorno consulta, ya que (no) ha cambiado los ajustes del dispositivo de salida:

gs -c "currentpagedevice {exch ==only () print == } forall" | grep Resolution 

Resultado:

HWResolution [86.5426483 86.5426483] 
/.MarginsHWResolution [1152.0 1152.0] 

Com pare esto a

gs \ 
    -o /dev/null \ 
    -dNODISPLAY \ 
    -c "currentpagedevice {exch ==only () print == } forall" \ 
| grep Resolution 

Resultado:

/HWResolution [72.0 72.0] 
/.MarginsHWResolution [72.0 72.0] 

Así que, por favor, evitar esta trampa. Me caí con éxito hace unos años, y ni siquiera lo noté durante mucho tiempo ...

Ahora suponiendo que desea consultar la configuración predeterminada del dispositivo de escritura PDF, ejecute este:

gs \ 
    -o /dev/null \ 
    -sDEVICE=pdfwrite \ 
    -c "currentpagedevice {exch ==only () print == } forall" \ 
| tee ghostscript-pdfwrite-default-pagedevice-settings.txt 

Ahora tendrá todas las configuraciones para el dispositivo pdfwrite en un archivo * .txt.y es posible repetir que con algunos otros dispositivos de Ghostscript interesantes y luego compararlas para todas sus diferencias ampliada:

for _dev in \ 
    pswrite ps2write pdfwrite \ 
    tiffg3 tiffg4 tiff12nc tiff24nc tiff32nc tiff48nc tiffsep \ 
    jpeg jpeggray jpegcmyk \ 
    png16 png16m png256 png48 pngalpha pnggray pngmono; \ 
do \ 
    gs \ 
    -o /dev/null \ 
    -sDEVICE=${_dev} \ 
    -c "currentpagedevice {exch ==only () print == } forall" \ 
    | sort \ 
    | tee ghostscript-${_dev}-default-pagedevice-settings.txt; \ 
done 

Es bastante interesante comparar la configuración para, por ejemplo, los dispositivos pswrite y ps2write como esto (y también descubrir parámetros que están disponibles para el uno, pero no el otro dispositivo):

sdiff -sbB ghostscript-ps*write-default-pagedevice-settings.txt 

actualización:

Como se puede imaginar, esta es también una excelente manera de comparar diferentes versiones de Ghostscript y rastrear cómo la configuración predeterminada puede haber cambiado para diferentes dispositivos en versiones recientes. Esto es especialmente interesante si desea conocer todo el perfil de color recientemente implementado y el soporte ICC que ahora está presente en Ghostscript.

Además, para evitar el retorno de solo -dict- para ciertos valores de clave, utilice la macro === en lugar de ==. === actúa como == pero también imprime el contenido de diccionarios.

Así que aquí está la salida de ejemplo para el dispositivo pdfwrite. Recuerde, el dispositivo pdfwrite de Ghostscript está destinado a proporcionar la misma funcionalidad que Adobe Acrobat Distiller (con la función adicional de que no solo acepta PostScript como entrada, sino también archivos PDF, por lo que puede ordenar redistill archivos PDF existentes en orden para reparar, mejorar o de otra manera manipularlos).Por lo tanto, pdfdevice honores de Ghostscript la mayor parte del operador setdistillerparams la que el destilador original también es compatible con:

gs \ 
    -o /dev/null \ 
    -sDEVICE=pdfwrite \ 
    -c "currentpagedevice {exch ==only () print === } forall" \ 
| sort 

/%MediaDestination 0 
/%MediaSource 0 
/.AlwaysEmbed [] 
/.HWMargins [0.0 0.0 0.0 0.0] 
/.IgnoreNumCopies false 
/.LockSafetyParams false 
/.MarginsHWResolution [720.0 720.0] 
/.MediaSize [612.0 792.0] 
/.NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats] 
/ASCII85EncodePages false 
/AllowIncrementalCFF false 
/AllowPSRepeatFunctions false 
/AlwaysEmbed [] 
/AntiAliasColorImages false   [*] 
/AntiAliasGrayImages false   [*] 
/AntiAliasMonoImages false   [*] 
/AutoFilterColorImages true 
/AutoFilterGrayImages true 
/AutoPositionEPSFiles true 
/AutoRotatePages /PageByPage 
/BeginPage {--.callbeginpage--} 
/Binding /Left      [*] 
/BitsPerPixel 24 
/BlueValues 256 
/CalCMYKProfile (None)    [*] 
/CalGrayProfile (None)    [*] 
/CalRGBProfile (None)    [*] 
/CannotEmbedFontPolicy /Warning  [*] 
/CenterPages false 
/ColorACSImageDict << /Blend 1 /VSamples [2 1 1 2] /QFactor 0.9 /HSamples [2 1 1 2] >> 
/ColorConversionStrategy /LeaveColorUnchanged 
/ColorImageDepth -1 
/ColorImageDict << /Blend 1 /VSamples [2 1 1 2] /QFactor 0.9 /HSamples [2 1 1 2] >> 
/ColorImageDownsampleThreshold 1.5 
/ColorImageDownsampleType /Subsample 
/ColorImageFilter /DCTEncode 
/ColorImageResolution 150 
/ColorValues 16777216 
/Colors 3 
/CompatibilityLevel 1.4 
/CompressEntireFile false 
/CompressFonts true 
/CompressPages true 
/ConvertCMYKImagesToRGB false 
/ConvertImagesToIndexed true 
/CoreDistVersion 5000 
/CreateJobTicket false    [*] 
/DSCEncodingToUnicode [] 
/DefaultRenderingIntent /Default 
/DetectBlends true     [*] 
/DetectDuplicateImages true 
/DeviceGrayToK true 
/DeviceLinkProfile() 
/DoNumCopies false 
/DoThumbnails false     [*] 
/DocumentTimeSeq 0 
/DocumentUUID() 
/DownsampleColorImages false 
/DownsampleGrayImages false 
/DownsampleMonoImages false 
/EmbedAllFonts true 
/EmitDSCWarnings false    [*] 
/EncodeColorImages true 
/EncodeGrayImages true 
/EncodeMonoImages true 
/EncryptionR 0 
/EndPage {--.callendpage--}   [*] 
/FirstObjectNumber 1 
/FitPages false 
/ForOPDFRead false 
/GraphicICCProfile() 
/GraphicIntent 0 
/GraphicsAlphaBits 1 
/GrayACSImageDict << /Blend 1 /VSamples [2 1 1 2] /QFactor 0.9 /HSamples [2 1 1 2] >> 
/GrayImageDepth -1 
/GrayImageDict << /Blend 1 /VSamples [2 1 1 2] /QFactor 0.9 /HSamples [2 1 1 2] >> 
/GrayImageDownsampleThreshold 1.5 
/GrayImageDownsampleType /Subsample 
/GrayImageFilter /DCTEncode 
/GrayImageResolution 150 
/GrayValues 256 
/GreenValues 256 
/HWResolution [720.0 720.0] 
/HWSize [6120 7920] 
/HaveCIDSystem false 
/HaveTransparency true 
/HaveTrueTypes true 
/HighLevelDevice true 
/ImageICCProfile() 
/ImageIntent 0 
/ImageMemory 524288     [*] 
/ImagingBBox null 
/InputAttributes << 59 << /PageSize [612 792] >> 36 << /PageSize [649 918] >> 13 << /PageSize [595 842] >> 49 << /PageSize [354 499] >> 26 << /PageSize [2004 2835] >> 3 << /PageSize [792 1224] >> 62 << /PageSize [595 792] >> 39 << /PageSize [612 936] >> 16 << /PageSize [297 420] >> 52 << /PageSize [1460 2064] >> 29 << /PageSize [709 1001] >> 6 << /PageSize [2448 3168] >> 42 << /PageSize [396 612] >> 19 << /PageSize [105 148] >> 55 << /PageSize [516 729] >> 32 << /PageSize [2599 3677] >> 9 << /PageSize [1684 2384] >> 45 << /PageSize [1417 2004] >> 22 << /PageSize [1296 1728] >> 58 << /PageSize [612 1008] >> 35 << /PageSize [918 1298] >> 12 << /PageSize [842 1191] >> 48 << /PageSize [499 709] >> 25 << /PageSize [2835 4008] >> 2 << /PageSize [612 792] >> 61 << /PageSize [612 792] >> 38 << /PageSize [323 459] >> 15 << /PageSize [420 595] >> 51 << /PageSize [2064 2920] >> 28 << /PageSize [1001 1417] >> 5 << /PageSize [1585 2448] >> 64 << /PageSize [0 0 524287 524287] >> 41 << /PageSize [283 420] >> 18 << /PageSize [148 210] >> 54 << /PageSize [729 1032] >> 31 << /PageSize [354 499] >> 8 << /PageSize [2384 3370] >> 44 << /PageSize [2004 2835] >> 21 << /PageSize [864 1296] >> 57 << /PageSize [1224 792] >> 34 << /PageSize [1298 1837] >> 11 << /PageSize [1191 1684] >> 47 << /PageSize [709 1001] >> 24 << /PageSize [2592 3456] >> 1 << /PageSize [792 1224] >> 60 << /PageSize [612 792] >> 37 << /PageSize [459 649] >> 14 << /PageSize [595 842] >> 50 << /PageSize [2920 4127] >> 27 << /PageSize [1417 2004] >> 4 << /PageSize [1224 1585] >> 63 << /PageSize [792 1224] >> 40 << /PageSize [612 936] >> 17 << /PageSize [210 297] >> 53 << /PageSize [1032 1460] >> 30 << /PageSize [499 709] >> 7 << /PageSize [2016 2880] >> 43 << /PageSize [2835 4008] >> 20 << /PageSize [648 864] >> 56 << /PageSize [363 516] >> 33 << /PageSize [1837 2599] >> 10 << /PageSize [73 105] >> 46 << /PageSize [1001 1417] >> 23 << /PageSize [1728 2592] >> 0 << /PageSize [612.0 792.0] >> >> 
/Install {--.callinstall--} 
/InstanceUUID() 
/IsDistiller true 
/KeyLength 0 
/LZWEncodePages false 
/Margins [0.0 0.0] 
/MaxClipPathSize 12000 
/MaxInlineImageSize 4000 
/MaxPatternBitmap 0 
/MaxSeparations 3 
/MaxShadingBitmapSize 256000 
/MaxSubsetPct 100 
/MaxViewerMemorySize -1 
/MonoImageDepth -1 
/MonoImageDict << /K -1 >> 
/MonoImageDownsampleThreshold 1.5 
/MonoImageDownsampleType /Subsample 
/MonoImageFilter /CCITTFaxEncode 
/MonoImageResolution 300 
/Name (pdfwrite) 
/NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats] 
/NoEncrypt() 
/NoT3CCITT false 
/NumCopies null 
/OPM 1 
/OffOptimizations 0 
/Optimize false      [*] 
/OutputAttributes << 0 << >> >> 
/OutputDevice /pdfwrite 
/OutputFile (/dev/null) 
/OutputICCProfile (default_rgb.icc) 
/OwnerPassword() 
/PDFA 0 
/PDFACompatibilityPolicy 0 
/PDFEndPage -1 
/PDFStartPage 1 
/PDFX false 
/PDFXBleedBoxToTrimBoxOffset [0.0 0.0 0.0 0.0] 
/PDFXSetBleedBoxToMediaBox true 
/PDFXTrimBoxToMediaBoxOffset [0.0 0.0 0.0 0.0] 
/PageCount 0 
/PageDeviceName null 
/PageOffset [0 0] 
/PageSize [612.0 792.0] 
/ParseDSCComments true 
/ParseDSCCommentsForDocInfo true 
/PatternImagemask false 
/Permissions -4 
/Policies << /PolicyReport {--dup-- /.LockSafetyParams --known-- {/setpagedevice --.systemvar-- /invalidaccess signalerror} --if-- --pop--} /PageSize 0 /PolicyNotFound 1 >> 
/PreserveCopyPage true    [*] 
/PreserveDeviceN true 
/PreserveEPSInfo true    [*] 
/PreserveHalftoneInfo false   [*] 
/PreserveOPIComments true   [*] 
/PreserveOverprintSettings true 
/PreserveSMask true 
/PreserveSeparation true 
/PreserveTrMode true 
/PrintStatistics false 
/ProcessColorModel /DeviceRGB 
/ProduceDSC true 
/ProofProfile() 
/ReAssignCharacters true 
/ReEncodeCharacters true 
/RedValues 256 
/RenderIntent 0 
/RotatePages false 
/SeparationColorNames [] 
/Separations false 
/SetPageSize false 
/SubsetFonts true 
/TextAlphaBits 1 
/TextICCProfile() 
/TextIntent 0 
/TransferFunctionInfo /Preserve 
/UCRandBGInfo /Preserve 
/UseCIEColor false 
/UseFastColor false 
/UseFlateCompression true 
/UsePrologue false     [*] 
/UserPassword() 
/WantsToUnicode true 
/sRGBProfile (None)     [*] 

[*] Nota:

De acuerdo con la documentación oficial, los siguientes valores (que son compatibles por Adobe Acrobat Distiller) actualmente en Ghostscript se puede configurar y consultar, pero su configuración no tiene ningún efecto:

  • /AntiAliasColorImages
  • /AntiAliasGrayImages
  • /AntiAliasMonoImages
  • /AutoPositionEPSFiles
  • /Binding
  • /CalCMYKProfile
  • /CalGrayProfile
  • /CalRGBKProfile
  • /CannotEmbedFontPolicy
  • /ConvertImagesToIndexed
  • /CreateJobTicket
  • /DetectBlends
  • /DoThumbnails
  • /EmitDSCWarnings
  • /EndPage
  • /ImageMemory
  • /LockDistillerParams
  • /Optimize
  • /PreserveCopyPage
  • /PreserveEPSInfo
  • /PreserveHalftoneInfo
  • /PreserveOPIComments
  • /sRGBProfile
  • /StartPage
  • /UsePrologue
+1

Guau, increíble, muchas gracias por eso, @pipitas! Nunca había entendido lo que significa "intérprete de PostScript" hasta ahora. Es increíblemente útil tener documentados estos enfoques de comando ... Muchas gracias de nuevo. ¡Saludos! – sdaau

+0

@sdaau: He actualizado y ampliado un poco la respuesta original ... –

+0

Gracias por la actualización @pipitas: este es un recurso fantástico para tener en línea; ¡aclamaciones! – sdaau

Cuestiones relacionadas