pdf links

PDF Rendering
Convert PDF to Image (.NET)
Convert PDF to image on Android (Xamarin)
Convert PDF to image on iOS (Xamarin)
Convert PDF to image in Windows Store apps (.NET)
Convert PDF to image in Windows Phone apps (.NET)
PDF to image in Universal Windows Store apps (.NET)
Free PDF Viewer control for Windows Forms (.NET)
How to integrate PDF Viewer control in WPF app (.NET)
Creating WPF PDF Viewer supporting bookmarks (.NET)
Cross-platform PDF Viewer using GTK# (MONO)
Silverlight PDF viewer control (Silverlight 5)
Multithreaded PDF rendering (.NET)
Convert pdf to image in Silverlight app (C# sample)
How to set fallback fonts for PDF rendering (C#)
Avoiding the out-of-memory exception on rendering (C#)
PDF viewer single page application (WebAPI, AngularJS)
PDF viewer control for Windows 10 universal applications
Use custom ICC profile for CMYK to RGB conversion
PDF layers - separate images, text, annotations, graphics

PDF Forms Creation PDF Security
Conversion to PDF/A
Other topics
PDF Document Manipulation
PDF Content Generation
Fixed and Flow layout document API (.NET)
Creation of grids and tables in PDF (C# sample)
How to create interactive documents using Actions (C# sample)
Text flow effects in PDF (C# sample)
How to generate ordered and bulleted lists in PDF (C# sample)
Convert HTML to PDF using flow layout API (C# sample)
How to use custom fonts for PDF generation (.NET)
Create document with differently sized pages (C#)
Create PDF documents using MONO (C#/MONO/Windows/OSX)
How to use background images for content elements (C#/PDF Kit/FlowLayout)
Add transparent images to PDF document (C#)
Draw round rect borders in PDF documents(C#)
ICC color profiles and and ICC based colors in PDF (C#)
How to use bidirectional and right to left text in PDF (C#)
Create PDF documents from XML templates (C# sample)
How to resize PDF pages and use custom stamps (C#)
Add header and footer to PDF page (.NET sample)
How to use clipping mask for drawing on PDF page
Fill graphics path with gradient brushes in PDF (Shadings)
Apitron PDF Kit and Rasterizer engine settings
Add layers to PDF page (optional content, C# sample)
How to create free text annotation with custom appearance

PDF Content Extraction
PDF Navigation

PDF to TIFF conversion
Contact us if you have a PDF related question and we'll cover it in our blog.

2016-08-28

How to render and display PDF layers using advanced rendering settings



Introduction


Sometimes you need to display only a part of the actual content contained on the PDF doc’s page, or maybe just working on a custom PDF viewer with support for layers for different types of content. E.g. you may want to separate images, text, annotations, graphics paths etc. and allow users to switch between them. 

In this article we’ll show how to use rendering settings of Apitron PDF Rasterizer engine and get the desired layered rendering done. An advanced and complete code sample can be downloaded from our github repo, it’s called WpfPdfViewer.

 

The code



It’s very easy to turn desired layers of content on and off while rendering the PDF page, the only thing you need is to use the corresponding setting of the RenderingSettings class. See below:

RenderingSettings renderingSettings = new RenderingSettings();
renderingSettings.DrawText = true;
renderingSettings.DrawImages = true;
renderingSettings.DrawPaths = true;
renderingSettings.DrawAnotations = true;
renderingSettings.AnnotationRenderingSettings = new RenderingSettings();
renderingSettings.AnnotationRenderingSettings.DrawText = true;

//render the page using the settings created above
page.Render(72,72, renderingSettings);

As you can see, there’s nothing difficult here, you just set the corresponding boolean value and pass the settings object to the rendering function. It’s also possible to use separate rendering settings for annotations’ content, e.g. you can turn off the text rendering for annotations while leaving other textual context shown. A few images below demonstrate the effects of these settings.


Pic. 1 A completely rendered page

Pic. 1 A completely rendered page


Pic. 2 Images turned off

Pic. 2 Images turned off

 
Pic. 3 Text turned off

Pic. 3 Text turned off


Pic. 4 Graphics paths turned on

Pic. 4 Graphics paths turned on


Pic. 5 Graphics paths turned off

Pic. 5 Graphics paths turned off



 

Summary


As you could see from the examples shown, the Apitron PDF Rasterizer for .NET is a very versatile tool allowing you to handle all rendering task related to PDF rendering and also navigation (see the bookmarks tab on the left, it was created using rasterizer’s API). Contact us if you have any questions, we’re always ready to help you.