Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove Layers/Background from PDF in PHP/Bash/C#
    primarykey
    data
    text
    <p>I have some PDF files that I need to modify using a PHP script. I'm also able to exec() so I can use pretty much anything that runs on CentOS.</p> <p>The PDF files when opened through Adobe Acrobat Pro X, show 2 layers in the "layers" panel:</p> <ol> <li>Background</li> <li>Color</li> </ol> <p>When I disable both of these layers I end up with a black &amp; white text &amp; images (the text is not vector tho, it's a scanned document). </p> <p>I want to disable these layers and any other similar layer found in the PDFs using PHP and/or C# or any command-line tool.</p> <p>Other useful information:</p> <p>When I run pdfimages (provided with XPDF) on my PDFs, it extracts exactly what I actually need removed from each page...</p> <p>Additional Information Update: I modified the PDFSharp example here: <a href="http://www.pdfsharp.net/wiki/ExportImages-sample.ashx" rel="nofollow">http://www.pdfsharp.net/wiki/ExportImages-sample.ashx</a> :</p> <p>Modified:<br> Line 28: <code>ExportImage(xObject, ref imageCount);</code></p> <p>To:<br> <code>PdfObject obj = xObject.Elements.GetObject("/OC");</code><br> <code>Console.WriteLine(obj);</code></p> <p>I got the following output in the console for each image:<br> <code>&lt;&lt; /Name Background /Type /OCG &gt;&gt;</code><br> <code>&lt;&lt; /OCGs [ 2234 0 R ] /P /AllOff /Type /OCMD &gt;&gt;</code><br> <code>&lt;&lt; /Name Text Color /Type /OCG &gt;&gt;</code> </p> <p>Which is actually the layer information, and the PDFSharp Documentation for the /OC key:</p> <blockquote> <p>Before the image is processed, its visibility is determined based on this entry. If it is determined to be invisible, the entire image is skipped, as if there were no Do operator to invoke it.</p> </blockquote> <p>So now, how do I modify the /OC value to something that will make these layers invisible?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload