Print Page | Close Window

How to make duplicate pages without any reference?

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=2649
Printed Date: 02 Feb 26 at 10:03AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to make duplicate pages without any reference?
Posted By: ExchangeViews
Subject: How to make duplicate pages without any reference?
Date Posted: 22 May 13 at 9:25AM
Hi all, I have a pdf of 5 pages - 1,2,3,4,5. I want to make each page repeated like this - 1,1,2,2,3,3,4,4,5,5. I used CopyPageRangesEx(id,'1,1,2,2,3,3,4,4,5,5',1) and created a new pdf with duplicate pages. Now if I capture first page using CapturePageEx(I, 1), it makes the second page blank. What i want to capture the first page only without making second page blank. what function I need to use to make duplicate page content visible after previuos page capture?

ids:=QP.NewDocument;
QP.LoadFromFile(EditFileName.Text,'');
id:= QP.SelectedDocument;
QP.SelectDocument(ids);
QP.CopyPageRangesEx(id,'1,1,2,2,3,3,4,4,5,5',1);
QP.DeletePages(1,1);
QP.SelectPage(1);
QP.SetOrigin(1);
QP.SetCropBox(0, 0, QP.PageWidth/2, QP.PageHeight)
pid := QP.CapturePageEx(I, 1);
QP.InsertPages(1,1);
QP.SetPageSize('A4');
QP.DrawCapturedPage(pid, 0, 0,  QP.PageWidth, QP.PageHeight);

Thanks in advance.Clap





Replies:
Posted By: AndrewC
Date Posted: 23 May 13 at 5:13AM
Hello,

You  should maybe try calling QP.RemoveSharedContentStreams after calling CopyPageRangesEx.

Without testing, I suspect pages 1 and 2 (copy of page 1) share the same content stream so if you Capture the contentstream of page 1 then it also affects pages 2.  RemoveSharedContentStreams should fix this.

            QP.LoadFromFile("5pages.pdf", "");

            int id = QP.SelectedDocument();
            QP.NewDocument();

            int ret = QP.CopyPageRangesEx(id,"1,1,2,2,3,3,4,4,5,5",1) ;

            QP.RemoveSharedContentStreams();
            QP.DeletePages(1, 1);  // Remove the empty first page.

            int capID = QP.CapturePage(1);   // Copies and then deletes page 1
            QP.NewPage();                             // Add a new page at the end of the document

            QP.SetOrigin(1);
            QP.DrawCapturedPage(capID, 0, 0, QP.PageWidth() * 2, QP.PageHeight() * 4);

            QP.SaveToFile("out.pdf");


Andrew.


Posted By: ExchangeViews
Date Posted: 23 May 13 at 9:22AM
Hi AndrewC,

Great, it worked. Thanks again.Thumbs Up



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