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. 2 Images turned off
|
Pic. 3 Text turned off
|
Pic. 4 Graphics paths turned on
|
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.
No comments:
Post a Comment