How to turn layers on programatically in the PDFViewWPF viewer using C# .NET 4.0

已查看 77 次
跳至第一个未读帖子

John Ritchie

未读,
2014年7月25日 10:51:052014/7/25
收件人 pdfne...@googlegroups.com
I have followed the documentation and examples:
1) I can dump layers out to BMP - nice but not what I need
2) I can see and access all my layers by cycling through the Optional Content Groups.

What I can't do and is an absolute must is to be able to turn on a layer of my choosing in the viewer. I have tried to set the states on the config context, tried setting current and initial state on each OC group. And of course with each of my attempts I, at the end, update the PDFViewWPF viewer to reset to the document and to Update the Page Layout.

All I get is still just the initial drawing with no layers turned on. I also saw mention of a layers panel with the viewer, yet I can not find how to turn this on either.

Aaron

未读,
2014年7月25日 13:50:152014/7/25
收件人 pdfne...@googlegroups.com
Hello John,

You should be able to call Current_View.SetOCGContext() within PDFViewControl.xaml.cs.  Please let me know if this is not working for you.

John Ritchie

未读,
2014年7月25日 16:07:002014/7/25
收件人 pdfne...@googlegroups.com
On Friday, July 25, 2014 12:50:15 PM UTC-5, Aaron wrote:
> Hello John,
>
> You should be able to call Current_View.SetOCGContext() within PDFViewControl.xaml.cs.  Please let me know if this is not working for you.

That worked! Thank you very much!!

Shai Zaban

未读,
2015年2月1日 12:48:462015/2/1
收件人 pdfne...@googlegroups.com
Hi, It does not work for me.
How did you refresh the viewer?
Can you please post a sample code to show how to do that?

Thanks,
Shai


Ryan

未读,
2015年2月2日 13:44:112015/2/2
收件人 pdfne...@googlegroups.com
After calling SetOCGContext, you will want to call Update method to refresh the viewer.

Along with the PDFNet SDK for .Net there is also the regular PDFViewCtrl class, and samples, and these samples include a layers ui from which you can turn on/off layers. If you are having problems you may want to try the sample and verify exactly what each OCG layer is doing for the particular file(s) you are using.

Shai Zaban

未读,
2015年2月3日 15:08:442015/2/3
收件人 PDFTron PDFNet SDK on behalf of Ryan
Thanks, it is now working for me.
what I did is as follows, the order before might have been wrong:

Config init_cfg = doc.GetOCGConfig();

Context ctx = new Context(init_cfg);

ctx.SetState(group, state);

Current_View.SetOCGContext(ctx);

Current_View.Update();

 

On Mon, Feb 2, 2015 at 8:44 PM, Ryan via PDFTron PDFNet SDK <pdfnet-sdk+APn2wQeLvqS1aDfDhWC9f...@googlegroups.com> wrote:
After calling SetOCGContext, you will want to call Update method to refresh the viewer.

Along with the PDFNet SDK for .Net there is also the regular PDFViewCtrl class, and samples, and these samples include a layers ui from which you can turn on/off layers. If you are having problems you may want to try the sample and verify exactly what each OCG layer is doing for the particular file(s) you are using.

--
You received this message because you are subscribed to the "PDFTron PDFNet SDK" group (http://www.pdftron.com/pdfnet/forum.html).
---
You received this message because you are subscribed to a topic in the Google Groups "PDFTron PDFNet SDK" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pdfnet-sdk/nLxPoUh2zWA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pdfnet-sdk+...@googlegroups.com.
To post to this group, send email to pdfne...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

回复全部
回复作者
转发
0 个新帖子