TE Edit Control .NET Core / .NET Framework Help
Product page

PDF Support

The PDF Support can be incorporated into the editor using WinPdf Converter. Please visit our web site: www.subsystems.com if you wish to puchase WinPdf Converter.

Copy the pdn17.dll file from the WinPDF distribution to a location accessible by your application. Now include a reference to the pdn17.dll in your application. You can now use the following code to generate PDF from the current document:

C# Example

Pdn pdf=new Pdn();
pdf.LicenseKey="";   // Set the WinPdf product license key
int TotalPages=tern.TerGetParam(tc.TP_TOTAL_PAGES);
pdf.PdcStartDoc("test.pdf");    // start the pdf engine
tern.TerSetPrintPreview(true);  // start the document metafile
                                   output
for (int page=0;page<TotalPages;page++) {
  int width,height;
  tern.TerGetPageOrientEx(page,out width,out height);  
          // width/height (in current orientation) is returned
             in twips units
  pdf.PdcStartPage(width,height); 
          // pass width/height in twips
  pdf.PdcDrawMetafile(tern.TerPageMetafilePdf(page),300,300);   
         // TerPageMetafilePdf creates pages in 1/300 inches
            resolution
  pdf.PdcEndPage();
  TotalPages=tern.TerGetParam(tc.TP_TOTAL_PAGES);   
         // this line is needed only if the Tern control is NOT
            set to use page-mode
}
tern.TerSetPrintPreview(false);  
         // end the document metafile output
pdf.PdcEndDoc();   // close the pdf file

VB.NET Example

        Dim pdf As Pdn
        Dim TotalPages As Integer
        Dim page, width, height As Integer
        pdf = New Pdn()
        pdf.LicenseKey = "xyz"  ' replace with your license number
        TotalPages = Tern1.TerGetParam(tc.TP_TOTAL_PAGES)
        pdf.PdcStartDoc("test.pdf")       ' start the pdf engine
        Tern1.TerSetPrintPreview(True)  ' start the document metafile output
        For page = 0 To TotalPages - 1
            Tern1.TerGetPageOrientEx(page, width, height)  ' width/height (in current orientation) is returned in twips units
            pdf.PdcStartPage(width,height) ' pass width/height in twips
            pdf.PdcDrawMetafile(Tern1.TerPageMetafile(page), 300, 300) ' TerPageMetafile creates pages in 1/300 inches resolution
            pdf.PdcEndPage()
            TotalPages = Tern1.TerGetParam(tc.TP_TOTAL_PAGES) ' this line is needed only if the Tern control is NOT set to use page-mode
        Next page
        Tern1.TerSetPrintPreview(False)  ' end the document metafile output
        pdf.PdcEndDoc()   ' close the pdf file