Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone know how to delete a layer from a PDF file (not strictly VFP, but it's for a VFP app)...

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,340
FR
Hi All

I need to remove a layer (Optional Content Group in Acrobat speak) from a PDF

I've looked and looked and can't see any tools to do this.

Any help appreciated.

I have come up with a hack, which is to read the file into a string and turn off the visibility
and printing using a strtran() but it seems clumsy.

Very tenuous link to VFP - the reference to strtran()


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I will begin by saying that I have no personal experience with this, but I will first ask...
1. Is this a one-time need?
2. Or is this an on-going need?

If a one time need, then I'd recommend looking at doing it totally outside of VFP.
If an on-going need then, unless your STRTRAN() approach works fine for you, I'd recommend using a 3rd party API.

On doing a Google search I did find one API possibility (again I have not used it).
Look at the Answer (A:) on: Perhaps that might lead you to a solution.

Good Luck,
JRB-Bldr
 
Hi JRB-Bldr

I followed the link and it seemed to imply that if you had the SDK, and waited a bit, there might be a solution in the future
(future for 2008)... uncharacteristically Adobe have not yet delivered on this one.

This is an ongoing need, I have an application that stamps a jpg QR code on documents in PDF format, it's not bad, and uses
a 3rd party utility to do the stamping - maybe a few thousand or so PDF each week.

Sometimes people want the PDF without the QR code, and recently some PDF providers have moved to a PDF creator called BioPDF,
and my stamper corrupts the PDF in the current mode of operation - which allows for the removal of the stamp.

The stamper also allows for the stamp to be put in a named layer, but then provide no facility to remove the stamp.

Because I always use the same stamper, I can hide the layer from view and printing by a bit of find and replace - reading
the file into a string and using STRTRANS to set the viewing off and printing off. But in an ideal world I would like the
jpg removed entirely - because I suspect I will get more PDFs in future based on the ones I am hacking, which have the named
layer already hidden, which I will need to stamp with a new jpg... and be able to remove - if you follow me.

I have looked and can find no 3rd party utility to remove or edit layers, not even from Adobe, in any command line mode.

Hence posting here

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Hi Olaf

Storage and back-up Olaf, already running in Terabytes, need to manage the storage.

It is one approach though, only really need to back-up the originals, because you can make the
stamped ones again, at the moment I keep the stamped ones and not the ones without stamps.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I thought it might be a security risc to store unstamped file versions, if it's merely about the size, that shouldn't really be a problem.

Indeed it's the simplest thing to keep the originals to be able to revert to an unstamped version. For your situation now, if you don't have any file structure info you might get an idea by comparing unstamped and stamped file version. You could test that with any sample PDF, eg most probably the easiest comparison would be against a blank page PDF. I'd expect a main change being a new section at the end of the file, and some bytes in a document header or whatever document position defining a layer and pointing/referencing that stamp picture. You most probably know that reference section already, as you modify some bits there. These sections obviously need to be removed keeping the rest of the file and its references intact.

I haven't googled PDF file structures or have any experience with PDF libraries, so I can't help with the details.

Bye, Olaf.
 
>Very tenuous link to VFP - the reference to strtran()

By the way, it's also possible to do "string" processing of a file in other languages. For example in C# you have a simple method to read in a file, too via System.IO.File.ReadAllText(filename), especially when reading it in ANSI encoding (1 byte per char) and not Unicode. It's just a hack in any language to do some replacements of binary data via string manipulations. In C# you would rather use the ReadAllBytes() method to get a byte array of the file or of course go the classic route of processing a file as file stream.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top