Writing from gonum/plot to gofpdf package directly over interface

xuanbao · · 407 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello,</p> <p>I&#39;m trying to connect the output of two packages, but having problems to do so. I&#39;m creating a plot with the gonum/plot package. There are options to save the plot as jpg or pdf format, and the possibility to write the output to an IO writer:</p> <pre><code>c := vgpff.New(3*vg.Inch, 3*vg.Inch) p.Draw(draw.New(c)) // Write the Canvas to a io.Writer (in this case, os.Stdout). if _, err := c.WriteTo(os.Stdout); </code></pre> <p>now what I want embedd this PDF into another PDF that I created with the jung-kurt/gofpdf package, since I want to add extra info to the plot, like header etc.</p> <p>The gofpdf package has a method to write to a PDF file directly from a buffer:</p> <pre><code>func (f *Fpdf) RawWriteBuf(buf *bytes.Buffer) </code></pre> <p>My question is, is it possible to write the plot data to a buffer and use the RawWriteBuf method to embedd this data into my PDF file?</p> <p>If yes, how could I wrap the WriteTo method so it writes to a buffer?</p> <hr/>**评论:**<br/><br/>tiberiousr: <pre><pre><code>var b *bytes.Buffer c.WriteTo(b) f.RawWriteBuf(b) </code></pre> <p>Something like that anyway</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

407 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传