2012-06-19 53 views
1

我有我用來得到一個PDF文檔中的總頁數以下:ImageMagick的 - 取消警告消息

identify -format %n test.pdf 

我然後剝離所有非數字字符來從響應一個整數。

偶爾會產生以下錯誤,導致上述錯誤頁數不正確,因爲它們是與響應中的頁面無關的其他數字。

**** Warning: Fonts with Subtype = /TrueType should be embedded. 
      The following fonts were not embedded: 
        Arial 
        Arial,Bold 
        Arial,Italic 
        Times New Roman 

    **** This file had errors that were repaired or ignored. 
    **** The file was produced by: 
    **** >>>> Microsoft« Office Word 2007 <<<< 
    **** Please notify the author of the software that produced this 
    **** file that it does not conform to Adobe's published PDF 
    **** specification. 

    9 

「9」是文檔中的頁數。

如何執行我禁止警告消息,我試圖使用「-quiet」標誌但消息仍然生成。

+0

伊夫設法通過爆炸換行符的響應,只使用包含頁數最後來解決這個問題。 – jhdevuk

+1

警告可能不是Imagemagick,但可能來自Ghostscript。 – Bonzo

回答

2

警告到stderr這麼一個簡單的輸出重定向將這樣的伎倆:

identify -format %n test.pdf 2>/dev/null