difficult to copy elements of some spot color

Hi, i have a page that i would like to remove all elements that are not of some colorspace. This works very well to documents with mediabox = cropbox, but when they are different, the content of e_form is moved. I would like to maintan elements on original position.

The code to handle e_form is the same of ElementEdit

case Element.e_form: {
   writer.writeElement(element); // write Form XObject reference to current stream
   Obj form_obj = element.getXObject();
   if (!visited.contains((int) form_obj.getObjNum())) // if this XObject has not been processed
   {
       // recursively process the Form XObject
       visited.add((int) form_obj.getObjNum());
       ElementWriter new_writer = new ElementWriter();
       reader.formBegin();
       new_writer.begin(form_obj);
       doIt(type, reader, new_writer);
       new_writer.end();
       reader.end();
   }

Any tip will be appreciated. Thanks in advance.

Jef

Hello Jef,

It sounds like there may be some entries in the Form Xobject you may need to copy over. Please see the following for more details:

https://groups.google.com/d/msg/pdfnet-sdk/t0xlC27i10Q/xdJLPXUakLoJ

The above code (based on current ElementEdit sample) should keep BBox, Matrix, and other XObject entries intact, so it is unclear where is the problem.

One thing to keep in mind is that if the crop box is not the same as media box your page origin may not be 0,0. You could use GetDefaultMatrix (

https://groups.google.com/forum/#!searchin/pdfnet-sdk/GetDefaultMatrix) to transform points back and forth between cropped and rotated color space.

But again since it seems you are not directly testing for any intersections in is unclear where is the issue. If you could share a sample file along with a short code snippet we will take a further look.