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 - Image in OCG aka Layer
  FAQ FAQ  Forum Search   Register Register  Login Login

Image in OCG aka Layer

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


Joined: 19 Feb 15
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Koov Quote  Post ReplyReply Direct Link To This Post Topic: Image in OCG aka Layer
    Posted: 19 Feb 15 at 1:12PM
Hello,

I have a PDF file (mostly text in table). I want to add 2 images to 1st page below the text, in the way that one will be visible on PC, second - printed. If something is wrong (unsupported reader), I want that visible one to be printed.
I came up with this code, but it does not work. Images are 5953/8419@720dpi and should take whole page.
// Create two new optional content groups

OCG1 = DPL.NewOptionalContentGroup("OCG 1");

OCG2 = DPL.NewOptionalContentGroup("OCG 2");

// Select the page that you want the OCGs to be

// associated with.

DPL.SelectPage(1);

// Specify top left corner for starting point

// of all drawing functions.

DPL.SetOrigin(1);

// Add OCG 1

DPL.NewContentStream();

DPL.SelectContentStream(1);

// Load your image into memory

DPL.AddImageFromFile("C:\Users\***.jpg", 0);

// Get width and height of the image

lWidth = DPL.ImageWidth();

lHeight = DPL.ImageHeight();

// Draw the image onto the page using the specified width/height

DPL.DrawImage(595, 842, lWidth, lHeight);

DPL.SetImageOptional(OCG1)

DPL.SetOptionalContentGroupVisible(OCG1, 1); // Set this OCG to be visible

DPL.SetOptionalContentGroupPrintable(OCG1, 1); // Set this OCG to be printable

// Add OCG 2

DPL.NewContentStream();

DPL.SelectContentStream(2);

// Load your image into memory

DPL.AddImageFromFile("C:\Users\***2.jpg", 0);

// Get width and height of the image

lWidth = DPL.ImageWidth();

lHeight = DPL.ImageHeight();

// Draw the image onto the page using the specified width/height

DPL.DrawImage(595, 842, lWidth, lHeight);

DPL.SetImageOptional(OCG2)

DPL.SetContentStreamOptional(OCG2);

DPL.SetOptionalContentGroupVisible(OCG2, 1); // Set this OCG to be visible

DPL.SetOptionalContentGroupPrintable(OCG2, 0); // Set this OCG to be not printable

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