Skip to content

Conversation

Moneema14
Copy link

There is a clippingpath transformation method in ParserGraphicsState.cs file. Which is a Private method and we cant use it for other any kind of path. So, to extract path(not clipping path) from pdf files we need a path transformation method. This changes allow us to transform extracting path to userspace

@Moneema14 Moneema14 closed this Oct 5, 2018
@Moneema14 Moneema14 reopened this Oct 5, 2018
public Path TransformPath(Matrix ctm)
{
Path transformedPath = new Path();
foreach (Subpath subpath in subpaths)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you don't use 'var'?


return transformedCurve;
}
catch (Exception e)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to log exception! Why you use try-catch construction and throw exception? Its not correct!

/// </summary>
/// <param name="ctm">the matrix for the transformation</param>
/// <returns>the transformed shape</returns>
IShape TransformToUserspace(Matrix ctm);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Open Closed Principle(second SOLID principle) You need to extend abstractions! Will add a new interface with a IShape TransformToUserspace method!


AffineTransform t = new AffineTransform(ctm.Get(Matrix.I11), ctm.Get(Matrix
.I12), ctm.Get(Matrix.I21), ctm.Get(Matrix.I22), ctm.Get(Matrix.I31), ctm.Get(Matrix.I32));
//t = t.CreateInverse();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

}
catch (Exception e)
{
throw new Exception(e.Message, e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add logging

@avlemos
Copy link

avlemos commented Dec 30, 2019

Hi @Excalib88 ,
Thank you for your contribution. Just wanted to let you know that this will get picked up by our development team (it is currently on our backlog).

@introfog
Copy link
Contributor

introfog commented Jan 15, 2020

Hi @Moneema14
I'm from the iText Dev team
We looked at your pull request, we liked the idea, thanks for your contribution.
There are 2 comments:

  1. Adding a public method to the IShape interface is breaking changes.
  2. Duplication of code from the ParserGraphicsState class is not good.

As a result, we offer you the following corrections:

  1. Create an ShapeTransformUtil class in the com.itextpdf.kernel.geom package, and add 3 methods (pathTransform, lineTransform and bezierCurveTransform).
  2. Remove the methods (transformSubpath, transformSegment, transformPoints) in the ParserGraphicsState class and replace them with a method call from the ShapeTransformUtil class.
  3. Please, squash your commits into one.

Also, according to iText Contributor License Agreement, for any non-trivial (more than 20 significant lines of code) pull request, we need a signed CLA to be in the clear regarding IP.

We are waiting for your reply.

@Snipx
Copy link
Contributor

Snipx commented Feb 5, 2020

Hi @Moneema14, thanks again for the contribution and sorry for the delay. We have added a possibility to transform shapes to user space in commit 7ef8601
It's done in a different way compared to what you proposed, but that should do the trick for your use case.

I am now going to close this pull request. Your contribution suggestions are always welcome!

Best,
Alexey

@Snipx Snipx closed this Feb 5, 2020
@Snipx
Copy link
Contributor

Snipx commented Aug 4, 2020

Hi @Moneema14, we are looking for a way to contact you to discuss one small topic regarding your contribution. Would you be available for that? If so, could you type me at alexey.subach[at]itextpdf.com ? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants