mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-14 19:29:50 +08:00
Optimizer compress streams - improved detection of raw streams
This commit is contained in:
parent
6845f280a4
commit
cdab3285a1
@ -23,9 +23,17 @@ func (c *CompressStreams) Optimize(objects []core.PdfObject) (optimizedObjects [
|
||||
if !isStreamObj {
|
||||
continue
|
||||
}
|
||||
if _, found := core.GetName(stream.PdfObjectDictionary.Get("Filter")); found {
|
||||
continue
|
||||
// Skip objects that are already encoded.
|
||||
// TODO: Try filter combinations, and ignoring inefficient filters.
|
||||
if obj := stream.Get("Filter"); obj != nil {
|
||||
if _, skip := core.GetName(obj); skip {
|
||||
continue
|
||||
}
|
||||
if arr, ok := core.GetArray(obj); ok && arr.Len() > 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
encoder := core.NewFlateEncoder() // Most mainstream compressor and probably most robust.
|
||||
var data []byte
|
||||
data, err = encoder.EncodeBytes(stream.Stream)
|
||||
|
Loading…
x
Reference in New Issue
Block a user