'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.GraphicsImportsGrapeCity.Documents.Drawing '' This sample shows how to easily 'flatten' an AcroForm PDF with data -'' i.e. convert that form into a non-form PDF that looks Like the'' original filled form.'' The original filled form loaded by this sample Is generated by FormFields.PublicClassFlattenFormFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "form-fields.pdf"))'' Load the filled PDF form into a temp document:Dim srcDoc = NewGcPdfDocument() srcDoc.Load(fs)'' Draw all pages And annotation of the source PDF into the New one:ForEach srcPage In srcDoc.PagesDim page = doc.Pages.Add()Dim fxo = NewFormXObject(doc, srcPage) page.Graphics.DrawForm(fxo, page.Bounds, Nothing, ImageAlign.Default)'' This method draws all annotations on the page including form field widgets: srcPage.DrawAnnotations(page.Graphics, page.Bounds)Next'' Done: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass