Print Page | Close Window

Image in OCG aka Layer

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3078
Printed Date: 31 Jan 26 at 6:43AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Image in OCG aka Layer
Posted By: Koov
Subject: Image in OCG aka Layer
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk