summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--font.go10
-rw-r--r--fpdf.go18
-rw-r--r--util.go2
3 files changed, 15 insertions, 15 deletions
diff --git a/font.go b/font.go
index 35f59f1..4d151c2 100644
--- a/font.go
+++ b/font.go
@@ -144,22 +144,22 @@ type segmentType struct {
data []byte
}
-func segmentRead(f *os.File) (s segmentType, err error) {
- if err = binary.Read(f, binary.LittleEndian, &s.marker); err != nil {
+func segmentRead(r io.Reader) (s segmentType, err error) {
+ if err = binary.Read(r, binary.LittleEndian, &s.marker); err != nil {
return
}
if s.marker != 128 {
err = fmt.Errorf("font file is not a valid binary Type1")
return
}
- if err = binary.Read(f, binary.LittleEndian, &s.tp); err != nil {
+ if err = binary.Read(r, binary.LittleEndian, &s.tp); err != nil {
return
}
- if err = binary.Read(f, binary.LittleEndian, &s.size); err != nil {
+ if err = binary.Read(r, binary.LittleEndian, &s.size); err != nil {
return
}
s.data = make([]byte, s.size)
- _, err = f.Read(s.data)
+ _, err = r.Read(s.data)
return
}
diff --git a/fpdf.go b/fpdf.go
index 6ca64c6..8ab2339 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -2897,16 +2897,16 @@ func (f *Fpdf) parsepng(r io.Reader, readdpi bool) (info *ImageInfoType) {
return f.parsepngstream(buf, readdpi)
}
-func (f *Fpdf) readBeInt32(buf *bytes.Buffer) (val int32) {
- err := binary.Read(buf, binary.BigEndian, &val)
+func (f *Fpdf) readBeInt32(r io.Reader) (val int32) {
+ err := binary.Read(r, binary.BigEndian, &val)
if err != nil {
f.err = err
}
return
}
-func (f *Fpdf) readByte(buf *bytes.Buffer) (val byte) {
- err := binary.Read(buf, binary.BigEndian, &val)
+func (f *Fpdf) readByte(r io.Reader) (val byte) {
+ err := binary.Read(r, binary.BigEndian, &val)
if err != nil {
f.err = err
}
@@ -2968,12 +2968,12 @@ func (f *Fpdf) out(s string) {
}
// Add a buffered line to the document
-func (f *Fpdf) outbuf(b *bytes.Buffer) {
+func (f *Fpdf) outbuf(r io.Reader) {
if f.state == 2 {
- f.pages[f.page].ReadFrom(b)
+ f.pages[f.page].ReadFrom(r)
f.pages[f.page].WriteString("\n")
} else {
- f.buffer.ReadFrom(b)
+ f.buffer.ReadFrom(r)
f.buffer.WriteString("\n")
}
}
@@ -2990,8 +2990,8 @@ func (f *Fpdf) RawWriteStr(str string) {
// generation buffer. This is a low-level function that is not required for
// normal PDF construction. An understanding of the PDF specification is needed
// to use this method correctly.
-func (f *Fpdf) RawWriteBuf(buf *bytes.Buffer) {
- f.outbuf(buf)
+func (f *Fpdf) RawWriteBuf(r io.Reader) {
+ f.outbuf(r)
}
// Add a formatted line to the document
diff --git a/util.go b/util.go
index 149271c..2c8c5bb 100644
--- a/util.go
+++ b/util.go
@@ -93,7 +93,7 @@ func sliceCompress(data []byte) []byte {
// Returns an uncompressed copy of the specified zlib-compressed byte array
func sliceUncompress(data []byte) (outData []byte, err error) {
- inBuf := bytes.NewBuffer(data)
+ inBuf := bytes.NewReader(data)
r, err := zlib.NewReader(inBuf)
defer r.Close()
if err == nil {