Print Page | Close Window

How to preview selected Content Stream?

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=2305
Printed Date: 10 May 25 at 4:50PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to preview selected Content Stream?
Posted By: ExchangeViews
Subject: How to preview selected Content Stream?
Date Posted: 19 Jun 12 at 1:18PM
How can I see the Selected Content Stream? I have a pdf with 2 Content Stream count. I want to see the preview of selected Content Stream to delete. Can anyone please help me? I am using following code:
  QP:=TQuickPDF0815.Create;
  QP.UnlockKey('XXXXXXXX');
  QP.LoadFromFile(ListView1.Items[0].SubItems[2],'');
  //ShowMessage(IntToStr(QP.ContentStreamCount)); (2)
  QP.SelectContentStream(2);
  QP.DeleteContentStream;
  QP.SaveToFile('d:\new.pdf');

Many thanks in advance.



Replies:
Posted By: AndrewC
Date Posted: 20 Jun 12 at 12:12PM
It is not always safe to delete a content stream unless the PDF is created with this deletion in mind.

Content streams are like a pages of a book.  Sentences, words, paragraphs can be broken across multiple pages.  If you rip out a page then it it very likely that the book no longer makes sense - ie broken words, sentence, paragraph.  If the page was a single page chapter then it might be possible to rip out the page but still be able to read the book without syntax or spelling errors but the but book has to be designed that way in the first place.

There are no fixed rules as to how content streams are to be stored.

ContentStream 1=   "The Quick"
ContentStream 2=   "brown fo"
ContentStream 3=   "x jumped over the "
ContentStream 4=   "lazy "
ContentStream 5=   "dogs back"

If you delete stream 4 then it reads "the quick brown fox jumped over the dogs back"
If you delete stream 2 then it reads "the quick x jumped over the lazy dogs back"

A PDF works in exactly the same way and if there is a syntax error then the PDF can no longer be rendered correctly.

So it doesn't make sense to work with content streams.  You should look into OptionalContentGroups as they are designed to work as layers.

Andrew.


Posted By: ExchangeViews
Date Posted: 22 Jun 12 at 1:53PM
I have a pdf file which has a watermark on it. When i use ContentStreamCount, it shows 2 as count. Now i use following code:
QP.SelectContentStream(2);
  QP.DeleteContentStream;
  QP.SaveToFile('d:\new.pdf');
This new pdf is now watermark free. The only problem is that i want to preview both ContentStream to select an appropriate one to delete. 


Posted By: AndrewC
Date Posted: 23 Jun 12 at 8:54AM
Your approach may work on certain PDF files but it will not work on most PDF files.

There is no easy way.  You could delete the ContentStream, SaveToFile and then RenderPageToFile - Another option may be to copy the ContentStream to a string, replace it with a space character, call RenderPageToFile and then replace the ContentStream contents with the string you saved.



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