[ 
https://issues.apache.org/jira/browse/PDFBOX-4363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16668453#comment-16668453
 ] 

Emmeran Seehuber commented on PDFBOX-4363:
------------------------------------------

Sorry, I was not aware that PD is reserved for official PDF structures. 

I thought about a base class at first too. This is possible without problems 
using generics. See [^shadingpaint_generic_baseclass.patch]

But it introduces a hidden class cast (as all generics do). I.e. the first 
access to the shading using the concrete type of the derived class will 
internally cause a cast/type check on the type of the shading member. As this 
code path should not be extremely performance critical it shouldn't matter. And 
the JVM is nowadays very good at optimizing this out.

> [Patch] Add a common interface PDShadingPaint for all shading paints
> --------------------------------------------------------------------
>
>                 Key: PDFBOX-4363
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4363
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.12
>            Reporter: Emmeran Seehuber
>            Priority: Minor
>         Attachments: pdshadingpaint_base_interface.patch, 
> shadingpaint_generic_baseclass.patch
>
>
> The attached patch adds an common interface PDShadingPaint to all 
> PDShading-based Paint's. It allows to access the underlying PDShading object 
> and the matrix of the paint.
> At the moment it is not possible to access this fields without using dirty 
> accessibility hacks, see also [this 
> commit|https://github.com/rototor/pdfbox-graphics2d/commit/8603f6f9c781604d4684b8cb46499703c34b4711].
> Why would you need that? I need that for my 
> [PdfBoxGraphics2D|https://github.com/rototor/pdfbox-graphics2d] adapter. I 
> draw PDF pages using PDFRenderer/PageDrawer back into a PDF. While doing so I 
> derive from both classes and change / filter certain aspects of the PDF. One 
> use case is to extract a specific seperation color into its own PDF page, 
> remap it to another color and also draw some overfill (i.e. a additional 
> border of 0.5pt around all shapes drawn with this color). This so prepared 
> page is then used with a machine which glues foil (gold, silver or copper) on 
> the places marked with that color.
> You can look at an [example 
> here|https://github.com/rototor/pdfbox-graphics2d/blob/master/src/test/java/de/rototor/pdfbox/graphics2d/PdfRerenderTest.java],
>  it does not use a seperation color, but you should get the idea. 
> My long term goal is to be able to use PDFBox for all possible pre-press PDF 
> manipulations. E.g. changing/remapping colorspaces, resampling images to the 
> target resolution, ...
> At the moment I know of this "special cases" which will need a special 
> treatment, as they are normally handled through rendering them first into a 
> BufferedImage:
>  - Transparency groups
>  - Softmasks
> Are there other places which resort to rendering to a BufferedImage first?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to