- ''
- '' This code is part of Document Solutions for PDF demos.
- '' Copyright (c) MESCIUS inc. All rights reserved.
- ''
- Imports System.IO
- Imports System.Drawing
- Imports GrapeCity.Documents.Pdf
- Imports GrapeCity.Documents.Pdf.AcroForms
- Imports GrapeCity.Documents.Pdf.Graphics
- Imports GrapeCity.Documents.Drawing
- Imports GrapeCity.Documents.Text
- '' This sample shows how to convert all text in an existing PDF to glyph outlines.
- '' The resulting PDF will look exactly Like the original, but all glyphs in it
- '' will be rendered as graphics paths. This can be used to manipulate the paths,
- '' Or to make sure it will be impossible to copy Or search the text.
- '' Note that the resulting documents will have no fonts (see for example
- '' the Document Properties | Fonts tab in DsPdfViewer).
- '' The original PDF used by this sample was generated by Wetlands.
- Public Class TextToOutlines
- Function CreatePDF(ByVal stream As Stream) As Integer
- Dim doc = New GcPdfDocument()
- Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "Wetlands.pdf"))
- '' Load the source PDF into a temp document:
- Dim srcDoc = New GcPdfDocument()
- srcDoc.Load(fs)
- '' Draw all pages of the source document on pages of the New PDF:
- For Each srcPage In srcDoc.Pages
- Dim page = doc.Pages.Add(srcPage.Size)
- '' Setting Graphics.DrawTextAsPath to true makes all glyphs draw as graphics paths
- '' instead of rendering text using fonts:
- page.Graphics.DrawTextAsPath = True
- '' Draw the source page on the target:
- srcPage.Draw(page.Graphics, srcPage.Bounds)
- Next
- '' Done:
- doc.Save(stream)
- Return doc.Pages.Count
- End Using
- End Function
- End Class