Convenience functions to create streams and indirect objects.

This commit is contained in:
Gunnsteinn Hall 2017-06-28 15:14:25 +00:00
parent 3586509908
commit 53b9e8b99c

View File

@ -98,6 +98,27 @@ func MakeNull() *PdfObjectNull {
return &null
}
func MakeIndirectObject(obj PdfObject) *PdfIndirectObject {
ind := &PdfIndirectObject{}
ind.PdfObject = obj
return ind
}
func MakeStream(contents []byte, encoder StreamEncoder) (*PdfObjectStream, error) {
stream := &PdfObjectStream{}
stream.PdfObjectDictionary = encoder.MakeStreamDict()
encoded, err := encoder.EncodeBytes(contents)
if err != nil {
return nil, err
}
stream.PdfObjectDictionary.Set("Length", MakeInteger(int64(len(encoded))))
stream.Stream = encoded
return stream, nil
}
func (this *PdfObjectBool) String() string {
if *this {
return "true"