Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:25:16+00:00 2026-06-17T17:25:16+00:00

I mean using a c or c++ lib. to manipullate. former I use cairo

  • 0

I mean using a c or c++ lib. to manipullate. former I use cairo lib, successfully create the pdf file, but no layers. now I want to create pdf file with several layers.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:25:17+00:00Added an answer on June 17, 2026 at 5:25 pm

    You can create (also read and edit) PDF layers (also know an Optional Content Groups) as shown in PDFLayers sample which is also included as part of PDFNet SDK.

    The following is a relevant code:

        PDFNet.Initialize();
        PDFDoc doc;
    
        // Create three layers...
        OCG::Group image_layer = CreateLayer(doc, "Image Layer");
        OCG::Group text_layer = CreateLayer(doc, "Text Layer");
        OCG::Group vector_layer = CreateLayer(doc, "Vector Layer");
    
        // Start a new page ------------------------------------
        Page page = doc.PageCreate();
    
        ElementBuilder builder; // ElementBuilder is used to build new Element objects
        ElementWriter writer;   // ElementWriter is used to write Elements to the page  
        writer.Begin(page);     // Begin writing to the page
    
        // Add new content to the page and associate it with one of the layers.
        Element element = builder.CreateForm(CreateGroup1(doc, image_layer.GetSDFObj()));
        writer.WriteElement(element);
    
        element = builder.CreateForm(CreateGroup2(doc, vector_layer.GetSDFObj()));
        writer.WriteElement(element);
    
        // Add the text layer to the page...
        if (false)  // set to true to enable 'ocmd' example.
        {
            // A bit more advanced example of how to create an OCMD text layer that 
            // is visible only if text, image and path layers are all 'ON'.
            // An example of how to set 'Visibility Policy' in OCMD.
            Obj ocgs = doc.CreateIndirectArray();
            ocgs.PushBack(image_layer.GetSDFObj());
            ocgs.PushBack(vector_layer.GetSDFObj());
            ocgs.PushBack(text_layer.GetSDFObj());
            OCG::OCMD text_ocmd = OCG::OCMD::Create(doc, ocgs, OCG::OCMD::e_AllOn);
            element = builder.CreateForm(CreateGroup3(doc, text_ocmd.GetSDFObj()));
        }
        else {
            element = builder.CreateForm(CreateGroup3(doc, text_layer.GetSDFObj()));
        }
        writer.WriteElement(element);
    
        // Add some content to the page that does not belong to any layer...
        // In this case this is a rectangle representing the page border.
        element = builder.CreateRect(0, 0, page.GetPageWidth(), page.GetPageHeight());
        element.SetPathFill(false);
        element.SetPathStroke(true);
        element.GetGState().SetLineWidth(40);
        writer.WriteElement(element);
    
        writer.End();  // save changes to the current page
        doc.PagePushBack(page);
    
        // Set the default viewing preference to display 'Layer' tab.
        PDFDocViewPrefs prefs = doc.GetViewPrefs();
        prefs.SetPageMode(PDFDocViewPrefs::e_UseOC);
    
        doc.Save("my.pdf", SDFDoc::e_linearized, 0);
    

    Note: I am a PDFNet developer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using imgscalr-lib-3.1 to create thumbnails to use in my galleria-classic photo album.
I am trying to create a form using only JavaScript. I mean create a
If I want to create an identifying relationship using EF 4.1+ (or EF5 Beta),
I am using the md5.c file in an iOS app. http://opensource.apple.com/source/cvs/cvs-33/cvs/lib/md5.c?txt When I compile,
Using visual studio 2008, I have an .H and a .LIB file of a
I'm using the python UnRar2 file to unrar a file, but after I do
I am using JBOSS AS 7.0.2. I want to create a connection to mysql
I am trying to calculate a rolling mean using plyr. The data is at
am trying to calculate mean and variance using 3X3 window over image(hXw) in opencv...here
Does using Service Oriented Architecture (SOA) in a system mean it is a distributed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.