我想将powerpoint演示文稿转换为多个图像。我已经在我的服务器上安装了LibreOffice并将docx转换为pdf没问题。 pptx到pdf转换不起作用。我使用了以下命令行:
libreoffice --headless --convert-to pdf filename.pptx
有没有办法立即将pptx转换为pngs,还是先将其转换为pdf然后再使用ghostscript或其他东西?
那么质量设置呢?有没有办法选择得到的图像的分辨率?
提前致谢!
修改 根据{{3}},我能够使用简单的命令行将pdf转换为图像:
convert <filename>.pdf <filename>.jpg
(我猜你需要LibreOffice和ImageMagick,但不确定 - 在我的服务器上运行)
但是pptx-to-pdf转换仍然存在问题。
感谢谷歌搜索和Sebastian Heyn的帮助,我能用这条线创建一些高质量的图像:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
使用后请耐心等待 - 你仍然可以在unix控制台中键入soemthing但它正在处理中。只需等待几分钟,即可创建jpg文件。
有关这些选项的更多信息,请查看此this link
P.S。:pptx文件的宽高比似乎不完全是4:3,因为生成的图像大小为1950x1500
答案 0 :(得分:6)
安装unoconv和LibreOffice后,您可以使用:
unoconv --export Quality=100 filename.pptx filename.pdf
将您的演示文稿转换为PDF格式。如需更多选项,请查看here。
之后你可以 - 如上所述 - 使用:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
接收图片。
答案 1 :(得分:1)
不确定libreoffice,但afaik是唯一一个处理pptx文件的程序。
我发现了http://ask.libreoffice.org/en/question/23851/converting-pptx-to-pdf-issue/
如果你有pdf,你可以使用imagemagick输出任何高质量的图片
答案 2 :(得分:0)
此解决方案需要 LibreOffice ( import { mergeDeepRight } from 'ramda'
import {
GET_BALANCES,
GET_EXCHANGES,
SELECT_EXCHANGE,
GET_SYMBOL_PRICE_TICKER,
GET_DAY_CHANGE_TICKER,
GET_FRIEND_EXCHANGES,
ADD_EXCHANGE,
} from '../action-types/exchanges.action-types'
import { LOG_OUT, VALIDATE_TOKEN } from '../action-types/login.action-types'
import { ExchangeService } from '../constants/types'
// Exchanges Reducer
export type exchangeState = {
status: string
_id: string
label: string
displayName: string
dayChangeTicker: any
symbolPriceTicker: any
balances: any,
}
export type exchangesState = {
status: string
selectedExchange: exchangeState
addExchange: {
status: string,
}
exchanges: Array<ExchangeService>
friendExchanges: Array<ExchangeService>,
}
const initialExchangeState: exchangeState = {
status: 'pending',
_id: '',
label: '',
displayName: null,
dayChangeTicker: {},
symbolPriceTicker: {},
balances: {},
}
const initialState: exchangesState = {
status: 'pending',
selectedExchange: {
status: 'pending',
_id: '',
label: '',
displayName: null,
dayChangeTicker: {},
symbolPriceTicker: {},
balances: {},
},
addExchange: {
status: 'pending',
},
exchanges: [],
friendExchanges: [],
}
export default (state = initialState, action) => {
switch (action.type) {
case SELECT_EXCHANGE:
case GET_SYMBOL_PRICE_TICKER.SUCCESS:
case GET_DAY_CHANGE_TICKER.SUCCESS:
case GET_BALANCES.REQUEST:
case GET_BALANCES.SUCCESS:
case GET_BALANCES.FAILURE:
return { ...state, selectedExchange: selectedExchangeReducer(state.selectedExchange, action) }
case GET_EXCHANGES.REQUEST:
case GET_FRIEND_EXCHANGES.REQUEST:
return { ...state, status: 'loading' }
case GET_EXCHANGES.SUCCESS:
if (action.payload.exchanges.length > 0) {
return mergeDeepRight(state, {
exchanges: action.payload.exchanges,
selectedExchange: { ...action.payload.exchanges[0] },
status: 'success',
})
}
return { ...state, status: 'success' }
case GET_FRIEND_EXCHANGES.SUCCESS:
return { ...state, friendExchanges: action.payload.exchanges, status: 'success' }
case GET_EXCHANGES.FAILURE:
case GET_FRIEND_EXCHANGES.FAILURE:
return { ...state, message: action.payload.message, status: 'failure' }
case LOG_OUT.SUCCESS:
case VALIDATE_TOKEN.FAILURE:
return initialState
case ADD_EXCHANGE.REQUEST:
return { ...state, addExchange: { status: 'loading' } }
case ADD_EXCHANGE.SUCCESS:
return { ...state, addExchange: { status: 'success' } }
case ADD_EXCHANGE.FAILURE:
return { ...state, addExchange: { status: 'failure' } }
default:
return state
}
}
const selectedExchangeReducer = (state = initialExchangeState, action) => {
switch (action.type) {
case SELECT_EXCHANGE:
if (action.payload.exchange) {
return { ...state, ...action.payload.exchange }
}
return initialExchangeState
case GET_SYMBOL_PRICE_TICKER.SUCCESS:
const symbolPriceTicker = action.payload.data.data.reduce((result, ticker) => {
result[ticker.symbol] = ticker.price
return result
}, {})
return { ...state, symbolPriceTicker }
case GET_DAY_CHANGE_TICKER.SUCCESS:
const dayChangeTicker = action.payload.data.data.reduce((result, ticker) => {
result[ticker.symbol] = ticker.priceChangePercent
return result
}, {})
return { ...state, dayChangeTicker }
// Get selected exchange's balances
case GET_BALANCES.REQUEST:
return { ...state, status: 'loading' }
case GET_BALANCES.SUCCESS:
debugger
return {
...state,
balances: action.payload.balances,
status: 'success',
}
case GET_BALANCES.FAILURE:
return { ...state, balances: [], message: action.payload.message, status: 'failure' }
default:
return state
}
}
)和 Ghostscript (soffice
)
gs
然后两个步骤:
sudo apt install libreoffice ghostscript
soffice --headless --convert-to pdf prezentacja.pptx
gs -sDEVICE=pngalpha -o slajd-%02d.png -r96 prezentacja.pdf
-输出到文件,%02d slajd数字,两位数字-o slajd-%02d.png
-分辨率: