Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Optional Print Sections
  FAQ FAQ  Forum Search   Register Register  Login Login

Optional Print Sections

 Post Reply Post Reply
Author
Message
jt234 View Drop Down
Beginner
Beginner


Joined: 06 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote jt234 Quote  Post ReplyReply Direct Link To This Post Topic: Optional Print Sections
    Posted: 06 Sep 11 at 11:23PM
Hi,

I'm trying to add either a line or text (just an indicator, like an asterisk) to a PDF, but I'm trying to make them optionally printable (up to the user, armed only with the PDF file).  In Adobe Reader, when printing, the user has the option to print: Document, Document and Markup, Document and Stamps.  Are there any QuickPDF functions which I can use in the Markup or Stamps category that would fit this criteria?  I tried AddTextMarkupAnnotation, thinking 'Markup' might work, but it didn't work as expected.

Thanks!

-John
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 1:09PM
You should try Optional Content Groups.  These are like layers and can be made Optional for printing and viewing.  The layers show up in the left hand side panel in Acrobat next to the Outlines/Bookmarks, Thumbnails and Signatures toolbar panel.

  GetOptionalContentGroupPrintable
  SetOptionalContentGroupPrintable
  GetOptionalContentGroupVisible
  SetOptionalContentGroupVisible

You can also make form field printing optional with

  GetFormFieldPrintable
  SetFormFieldPrintable


Here is some 7.26 code that shows creation of a document with Optional Content Groups

private void button7_Click(object sender, EventArgs e)
        {
            // Create three new optional content groups
            int CapturedPageID;
            double PageHeight;
            double PageWidth;
            int fileA, fileB;
            int OCG_Back = 0;
            int layer;

            // True = create a background OCG layer.  False = Create a fixed background.
            bool useBackgroundOCG = true;

            QP.NewDocument();
            QP.SetOrigin(1);

            // Save file to disk with new layers

            PageHeight = QP.PageHeight();
            PageWidth = QP.PageWidth();

            // QP.SaveToFile("layers.pdf");
            fileA = QP.SelectedDocument();

            // You can only use the DrawCapturedPage function if the captured page is in the same
            // document, so first we'll need to merge the two pages that we wish to overlay together
            // into one document.

            //QP.LoadFromFile("debenu final tm.pdf");
            QP.LoadFromFile("JavaScript.pdf");
            fileB = QP.SelectedDocument();

            // After merging FileB is automatically deleted, leaving only FileB which is now a combination of FileA and FileB
            QP.SelectDocument(fileA);
            QP.MergeDocument(fileB);
            QP.SaveToFile("combined.pdf");

            // Capture the second page in the merged document
            CapturedPageID = QP.CapturePage(2);

            QP.SelectDocument(fileA);
            QP.SelectPage(1);
            
            // Create a background OCG if useBackgroundOCG = true

            if (useBackgroundOCG)
                OCG_Back = QP.NewOptionalContentGroup("Background");

            QP.DrawText(100, 100, "Background");

            // Draw the captured page onto the currently selected OCG

            int ret = QP.DrawCapturedPage(CapturedPageID, 0, 0, PageWidth, PageHeight);

            if (useBackgroundOCG)
            {
                QP.SetLayerOptional(OCG_Back);
                QP.SetOptionalContentGroupVisible(OCG_Back, 1);
            }

            // Now add the two OCG's with some text.

            int OCG1 = QP.NewOptionalContentGroup("Layer 1");
            int OCG2 = QP.NewOptionalContentGroup("Layer 2");

            // Select the page that you want the layers to be associated with.

            QP.SelectPage(1);

            // Add OCG 1

            layer = QP.NewLayer();
            QP.SelectLayer(layer);
            QP.DrawText(180, 100, "Layer 1");
            QP.SetLayerOptional(OCG1);
            QP.SetOptionalContentGroupVisible(OCG1, 1);

            // Add OCG 2

            layer = QP.NewLayer();
            QP.SelectLayer(layer);
            QP.DrawText(260, 100, "Layer 2");
            QP.SetLayerOptional(OCG2);
            QP.SetOptionalContentGroupVisible(OCG2, 1);

            // Save the stitched file to disk
            QP.SaveToFile("ocg.pdf");
            System.Diagnostics.Process.Start(@"ocg.pdf");
        }

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store