PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
[VB.NET]Create PDF document and show it in preview https://forum.pdfsharp.net/viewtopic.php?f=2&t=1989 |
Page 1 of 1 |
Author: | Renny [ Wed Apr 25, 2012 11:13 am ] |
Post subject: | [VB.NET]Create PDF document and show it in preview |
Hi Congratulation for Pdfsharp librery: it's the best! ![]() In my application, Icreate small reports with pdfsharp and I save the file .pdf.. All things works good. I would like to show my reports through pagepreview object I write this test code: Code: Imports PdfSharp.Drawing Imports PdfSharp Imports PdfSharp.Forms Imports System.Drawing Public Class Form1 Private mRenderEvent As PagePreview.RenderEvent Public WithEvents pdf As New RenderPdf Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'pg is pagepreview object in my main form Me.pg.SetRenderEvent(AddressOf pdf.render) 'delegate to sub render Dim pdfdocument As New PdfSharp.Pdf.PdfDocument Dim page As Pdf.PdfPage = pdfdocument.AddPage Dim gfx As XGraphics = XGraphics.FromPdfPage(page) gfx.DrawString("EXAMPLE TEXT", New XFont("Arial", 20), Brushes.Black, 10, 10) pdf.render(gfx) pdfdocument.Save("prova.pdf") End Sub Private Sub SetRenderEvent(ByVal renderEvent As PagePreview.RenderEvent) Me.pg.SetRenderEvent(renderEvent) mRenderEvent = renderEvent End Sub End Class 'renderpdf Public Class RenderPdf Public Sub render(ByVal gfx As XGraphics) '??? what code? End Sub End Class This code has no errors but the object pg does not display the text. How to display the document you created in the preview? Thank you. PS: sorry for my english ![]() |
Author: | Renny [ Fri Apr 27, 2012 7:23 am ] |
Post subject: | Re: [VB.NET]Create PDF document and show it in preview |
Hi! Can anyone help me? How do modify the Xgraphics object in render sub? Something like this: Code: Public Sub renderPage(ByVal RenderGfx As PdfSharp.Drawing.XGraphics) Dim document As New PdfDocument(filename) Dim page As PdfPage = document.AddPage() page.Size = PageSize.A4 RenderGfx = XGraphics.FromPdfPage(page) RenderGfx .DrawString("text", New XFont("Arial", 20), Brushes.Black, 20, 20) RenderGfx.Save() End Sub I would like show in preview my document... |
Author: | Thomas Hoevel [ Wed May 02, 2012 8:01 am ] |
Post subject: | Re: [VB.NET]Create PDF document and show it in preview |
Hi! Simple trick: use the XGraphics object that is passed as a parameter to your Render routine, don't assign a new value. For screen preview, you will receive an XGraphics object that draws on the screen. See the complete source code of the Preview sample (C# only) for further details. The Wiki only shows a snippet, but the complete source code is included in the sourcecode package. |
Author: | Renny [ Thu May 03, 2012 7:33 am ] |
Post subject: | Re: [VB.NET]Create PDF document and show it in preview |
Hi! thank you for responding! ![]() Well, I study the sample preview project attached the dll library and I understand the process. But, In my application I create a complex PDF of 3 pages with pfdSharp (for frame box) and MigraDoc (for table). Is there a way to show the complete document? some trick? How to use the same XGraphics object for multipage document? Thank you! ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |