summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--def.go15
-rw-r--r--fpdf.go32
2 files changed, 45 insertions, 2 deletions
diff --git a/def.go b/def.go
index 33eca47..15836d0 100644
--- a/def.go
+++ b/def.go
@@ -76,10 +76,23 @@ type ImageInfoType struct {
// value expressed in the unit of measure specified in New(). Since font
// management in Fpdf uses points, this method can help with line height
// calculations and other methods that require user units.
-func (f *Fpdf) PointConvert(pt float64) float64 {
+func (f *Fpdf) PointConvert(pt float64) (u float64) {
return pt / f.k
}
+// PointToUnitConvert is an alias for PointConvert.
+func (f *Fpdf) PointToUnitConvert(pt float64) (u float64) {
+ return pt / f.k
+}
+
+// UnitToPointConvert returns the value of u, expressed in the unit of measure
+// specified in New(), as a value expressed in points (1/72 inch). Since font
+// management in Fpdf uses points, this method can help with setting font sizes
+// based on the sizes of other non-font page elements.
+func (f *Fpdf) UnitToPointConvert(u float64) (pt float64) {
+ return u * f.k
+}
+
// Extent returns the width and height of the image in the units of the Fpdf
// object.
func (info *ImageInfoType) Extent() (wd, ht float64) {
diff --git a/fpdf.go b/fpdf.go
index 0fcc226..05598df 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -1528,7 +1528,8 @@ func (f *Fpdf) SetFont(familyStr, styleStr string, size float64) {
return
}
-// SetFontSize defines the size of the current font in points.
+// SetFontSize defines the size of the current font. Size is specified in
+// points (1/ 72 inch). See also SetFontUnitSize().
func (f *Fpdf) SetFontSize(size float64) {
if f.fontSizePt == size {
return
@@ -1540,6 +1541,19 @@ func (f *Fpdf) SetFontSize(size float64) {
}
}
+// SetFontUnitSize defines the size of the current font. Size is specified in
+// the unit of measure specified in New(). See also SetFontSize().
+func (f *Fpdf) SetFontSize(size float64) {
+ if f.fontSize == size {
+ return
+ }
+ f.fontSizePt = size * f.k
+ f.fontSize = size
+ if f.page > 0 {
+ f.outf("BT /F%d %.2f Tf ET", f.currentFont.I, f.fontSizePt)
+ }
+}
+
// GetFontSize returns the size of the current font in points followed by the
// size in the unit of measure specified in New(). The second value can be used
// as a line height value in drawing operations.
@@ -2849,6 +2863,22 @@ func (f *Fpdf) outbuf(b *bytes.Buffer) {
}
}
+// RawWriteStr writes a string directly to the PDF 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) RawWriteStr(str string) {
+ f.out(str)
+}
+
+// RawWriteBuf writes the contents of the specified buffer directly to the PDF
+// 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)
+}
+
// Add a formatted line to the document
func (f *Fpdf) outf(fmtStr string, args ...interface{}) {
f.out(sprintf(fmtStr, args...))