When we operate the Microsoft PowerPoint documents, we can set whether to show some additional information of slides to readers, such as “Date and Time”, “Slide number” and footer. This article will demonstrate how to set whether to show these information to readers in C# with the help of Spire.Presentation.

Firstly, view the screenshot of the property of slide appearance on the header and footer area.

Whether to display the additional information for presentation slides on header and footer area

Step 1: Create a presentation instance and load the document from file.

Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);

Step 2: Set the appearance property for slide number, footer and date time.

ppt.SlideNumberVisible = true;

ppt.FooterVisible = false;

ppt.DateTimeVisible = false;

Step 3: Save the document to file.

ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

Effective screenshot of the slide appearance on header and footer area.

Whether to display the additional information for presentation slides on header and footer area

Full codes of how to set the additional information of presentation slides’ header and footer area:

using Spire.Presentation;
using Spire.Xls;
namespace AdditionalInfo
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);

            ppt.SlideNumberVisible = true;

            ppt.FooterVisible = false;

            ppt.DateTimeVisible = false;

            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

        }
    }
}

PDF actions can refer to external files by using either absolute or relative file paths. While using the relative path in action, the file can be moved into a different location. In Spire.PDF, we can use the PdfLaunchAction to link to files with relative paths.

Code snippet:

Step 1: Create a new PDF document and add a page to it.

PdfDocument document = new PdfDocument();
PdfPageBase page = document.Pages.Add();     

Step 2: Create a PDF launch action that refers to an external file with relative path.

PdfLaunchAction launchAction = new PdfLaunchAction(@"..\..\test.txt", PdfFilePathType.Relative);

Step 3: Create a PDF action annotation with the launch action. Add the annotation to the page.

string text = "Click here to open file with relative path";
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 13f));
RectangleF rect = new RectangleF(50, 50, 230, 15);
page.Canvas.DrawString(text, font, PdfBrushes.ForestGreen, rect);
PdfActionAnnotation annotation = new PdfActionAnnotation(rect, launchAction);
(page as PdfNewPage).Annotations.Add(annotation);     

Step 4: Save the document.

document.SaveToFile("RelativeFilePath.pdf");

Screenshot:

Link to files with relative paths using PdfLaunchAction

Full code:

using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.Annotations;
using Spire.Pdf.Graphics;

namespace Link_to_files_with_relative_paths
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new PDF document and add a page to it
            PdfDocument document = new PdfDocument();
            PdfPageBase page = document.Pages.Add();

            //Create a PDF Launch Action       
            PdfLaunchAction launchAction = new PdfLaunchAction(@"..\..\test.txt", PdfFilePathType.Relative);
            
            //Create a PDF Action Annotation with the PDF Launch Action
            string text = "Click here to open file with relative path";
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 13f));
            RectangleF rect = new RectangleF(50, 50, 230, 15);
            page.Canvas.DrawString(text, font, PdfBrushes.ForestGreen, rect);
            PdfActionAnnotation annotation = new PdfActionAnnotation(rect, launchAction); 
             //Add the PDF Action Annotation to page
            (page as PdfNewPage).Annotations.Add(annotation);           

            //Save and close the document
            document.SaveToFile("RelativeFilePath.pdf");
            document.Close();
        }
    }
}

Spire.PDF provides support to render simple HTML string in a PDF document by using PdfHTMLTextElement class. (Only available on .NET, .Net Core/ .NET Standard doesn't offer PdfHTMLTextElement & PdfMetafileLayoutFormat class) This class supports a set of basic HTML tags including Font, B, I, U, Sub, Sup and BR. For complex HTML rendering with CSS, please check Convert HTML String to PDF.

Following code snippets demonstrates how we can insert HTML styled text to PDF.

Step 1: Create a new PDF document, add a page to it.

PdfDocument doc = new PdfDocument();
PdfNewPage page = doc.Pages.Add() as PdfNewPage;

Step 2: Define HTML string.

string htmlText= "This demo shows how we can insert <u><i>HTML styled text</i></u> to PDF using "
                 + "<font color='#FF4500'>Spire.PDF for .NET</font>. ";

Step 3: Render HTML text.

PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 5);
PdfBrush brush = PdfBrushes.Black;
PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(htmlText, font, brush);
richTextElement.TextAlign = TextAlign.Left;

Step 4: Format page layout to enable that the HTML text will break into multiple pages if the content exceeds one page.

PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
format.Break = PdfLayoutBreakType.FitPage;

Step 5: Draw HTML string on page.

richTextElement.Draw(page, new RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height/2),format);

Step 6: Save the document.

doc.SaveToFile("Output.pdf");

Output:

How to Insert HTML Styled Text to PDF in C#, VB.NET

Full Code:

[C#]
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;


namespace InsertHTMLStyledTexttoPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Pdf document
            PdfDocument doc = new PdfDocument();

            //Add a new page
            PdfNewPage page = doc.Pages.Add() as PdfNewPage;

            //HTML string
            string htmlText = "This demo shows how we can insert HTML styled text to PDF using "
                             + "Spire.PDF for .NET. ";

            //Render HTML text
            PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 5);
            PdfBrush brush = PdfBrushes.Black;
            PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(htmlText, font, brush);
            richTextElement.TextAlign = TextAlign.Left;

            //Format Layout
            PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
            format.Layout = PdfLayoutType.Paginate;
            format.Break = PdfLayoutBreakType.FitPage;

            //Draw htmlString  
            richTextElement.Draw(page, new RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height / 2), format);
            doc.SaveToFile("Output.pdf");
        }
    }
}
[VB.NET]
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing


Namespace InsertHTMLStyledTexttoPDF
	Class Program
		Private Shared Sub Main(args As String())
			'Create a Pdf document
			Dim doc As New PdfDocument()

			'Add a new page
			Dim page As PdfNewPage = TryCast(doc.Pages.Add(), PdfNewPage)

			'HTML string
			Dim htmlText As String = "This demo shows how we can insert HTML styled text to PDF using " + "Spire.PDF for .NET. "

			'Render HTML text
			Dim font As New PdfFont(PdfFontFamily.Helvetica, 5)
			Dim brush As PdfBrush = PdfBrushes.Black
			Dim richTextElement As New PdfHTMLTextElement(htmlText, font, brush)
			richTextElement.TextAlign = TextAlign.Left

			'Format Layout
			Dim format As New PdfMetafileLayoutFormat()
			format.Layout = PdfLayoutType.Paginate
			format.Break = PdfLayoutBreakType.FitPage

			'Draw htmlString  
			richTextElement.Draw(page, New RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height / 2), format)
			doc.SaveToFile("Output.pdf")
		End Sub
	End Class
End Namespace
page 205