使用 PDFSharp 在多页上打印位图图像,Vb.net

Print Bitmap image over multiple pages using PDFSharp, Vb.net

我有一个面板可以根据用户输入绘制图表。不幸的是,这些图表可能会变得非常非常大,当我打印它们时,它不能完全放在一页上而不失可读性。

我在 VB.net 中使用 PDFsharp 创建 PDF。目前的做法是将画图的面板转为位图图片,然后将图片放到pdf文档中。

1张图轻松做出1500,3000的面板

Example of Diagram

Example of Diagram in PDF

非常感谢任何帮助

        Dim pdfdoc As New PdfDocument
        Dim page As PdfPage = pdfdoc.AddPage
        Dim Bitmap As Bitmap = New Bitmap(pnl_Draw.Width, pnl_Draw.Height)
        Dim BXImage As XImage
        Dim GFX As XGraphics
        Me.pnl_Draw.DrawToBitmap(Bitmap, New Rectangle(0, 0, Bitmap.Width, Height))
        Dim pbx As New PictureBox
        pbx.Image = Bitmap
        BXImage = XImage.FromGdiPlusImage(pbx.Image)
        GFX = XGraphics.FromPdfPage(page)
        GFX.ScaleTransform(0.82)
        GFX.DrawImage(BXImage, 0, 0)
        GFX.Dispose()
        pdfdoc.Save("G:\test.pdf")
        pdfdoc.Close()
        Try
            Process.Start("G:\test.pdf")
        Catch ex As Exception
        End Try

简单的解决方案:在 Adob​​e Reader 打印对话框中单击 "Poster" 将图像打印在多页上。增加缩放系数,根据需要将海报分布在任意多的页面上。

您还可以根据位图大小按比例增加页面大小。

顺便说一句:如果您在 GFX.DrawImage.

的调用中指定目标大小,则不需要 GFX.ScaleTransform(0.82)