org.jpedal.parser.text.BDC Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
An Open Source JavaFX PDF Viewer
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2015 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---------------
* BDC.java
* ---------------
*/
package org.jpedal.parser.text;
import org.jpedal.io.ObjectDecoder;
import org.jpedal.io.PdfObjectReader;
import org.jpedal.objects.GraphicsState;
import org.jpedal.objects.raw.MCObject;
import org.jpedal.objects.raw.PdfDictionary;
import org.jpedal.objects.raw.PdfObject;
import org.jpedal.parser.ParserOptions;
import org.jpedal.render.DynamicVectorRenderer;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
public class BDC {
public static PdfObject execute(int startCommand, final int dataPointer, final byte[] raw, final String op,
final GraphicsState gs, final PdfObjectReader currentPdfFile, final DynamicVectorRenderer current, final ParserOptions parserOptions) {
final PdfObject BDCobj=new MCObject(op);
BDCobj.setID(PdfDictionary.BDC); //use an existing feature to add unknown tags
final int rawStart=startCommand;
if(startCommand<1) {
startCommand = 1;
}
boolean hasDictionary=true;
while(startCommand0 && clip.getBounds().getHeight()>0){
gs.setClippingShape(clip);
current.drawClip(gs,clip,true);
BDCobj.setClip(clip);
}
}
}else{ //direct just /OC and /MCxx
//find /OC
name = readOPName(dataPointer, raw, rawStart, name);
}
if(name!=null && !name.isEmpty()) //name referring to Layer or Title
{
parserOptions.setIsLayerVisible(parserOptions.layers.decodeLayer(name, true));
}
//flag so we can next values
if(parserOptions.isLayerVisible()) {
parserOptions.getLayerVisibility().add(parserOptions.getLayerLevel());
}
}
}
private static String readOPName(final int dataPointer, final byte[] raw, final int rawStart, String name) {
for(int ii=rawStart;ii