[
https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr updated PDFBOX-615:
-----------------------------------
Attachment: Type4ShadingPaint.java
Type4ShadingContext.java
Code for type 4 shading patterns (not shfill, because I don't have a test file)
attached, which works for the two adobe tests. I haven't solved the background
problem, I don't find anything in the specification how this should be done. It
supports only DeviceRGB and not functions. If you want to use the code, first
do this:
In PDShadingType4.java correct getFunction:
{code}
public PDFunction getFunction() throws IOException
{
if (function == null)
{
COSBase dictionaryFunctionObject =
getCOSDictionary().getDictionaryObject(COSName.FUNCTION);
if (dictionaryFunctionObject != null) //TH
function = PDFunction.create(dictionaryFunctionObject);
}
return function;
}
{code}
In PDShadingPatternResources.java, insert at case
PDShadingResources.SHADING_TYPE4:
{code}
case PDShadingResources.SHADING_TYPE4:
if (!(getShading().getColorSpace() instanceof PDDeviceRGB))
{
LOG.error("can't handle Colorspace " +
shading.getColorSpace());
return null;
}
paint = new Type4ShadingPaint((PDShadingType4) getShading(),
ctm, pageHeight);
break;
{code}
Get the Bitinput lib by adding this to the pdfbox pom.xml:
{code}
<dependency>
<groupId>com.github.jinahya</groupId>
<artifactId>bit-io</artifactId>
<version>1.0.3</version>
</dependency>
{code}
That lib has an apache 2.0 license :-)
The code works for the two Adobe demo files DECAHED.pdf and TRITYP4.pdf. It
does not work for ch14.pdf because 0) that pdf uses shfill 1) the vertex
streams in that file don't comply with the pdf spec (however creating a new pdf
from the ps file from the homepage
http://www.math.ubc.ca/~cass/graphics/manual/index.html creates a better file),
2) that pdf file has different color spaces than DeviceRGB and I need to learn
about these or get help with that segment of the code.
I think that the implementation for type4 shfill would be to use the gouraud
triangle mesh as a shape and pass this shape to graphics.fill() in
PageDrawer.java, and then again use the existing code. Currently, PageDrawer
passes the full page to graphics.fill() which is why the pages 1,13,15 and 20
are black.
I also had a look at type 5 shading spec. The only difference is that the
triangles are defined differently (lattice), but the rest is the same, so I
will handle this too when I have the time.
> shfill operator needs implementation
> ------------------------------------
>
> Key: PDFBOX-615
> URL: https://issues.apache.org/jira/browse/PDFBOX-615
> Project: PDFBox
> Issue Type: New Feature
> Components: PDModel
> Reporter: Daniel Wilson
> Assignee: Daniel Wilson
> Attachments: Centerplan.pdf, DECAHED.pdf, Type4ShadingContext.java,
> Type4ShadingPaint.java, axial-input-after.png, axial-input-before.png,
> axial-input.pdf, bugzilla843488.pdf, bugzilla843488.pdf-1.png,
> color_gradient.pdf, color_gradient.pdf-1.png, decahed.pdf-1.png,
> decahed.pdf-1.png, input.pdf, input1.png, pdfbox-1.8.patch, pdfbox.patch,
> pslib-shading.pdf, radial-input-after.png, radial-input-before.png,
> radial-input.pdf, shading_pattern.pdf, shading_pattern.pdf-2.png,
> trityp4.pdf-1.png
>
>
> I have a PDF file (for which I do not yet have release permission) that uses
> the "sh" operator, equivalent to PostScript's shfill (per PDF spec 1.7 page
> 987).
> Adobe provides implementation guidance in a 78-page document at
> http://www.adobe.com/devnet/postscript/pdfs/TN5600.SmoothShading.pdf#17
> I will be trying to add this functionality this week, but if anyone has
> hints, suggestions, etc. they are most certainly welcome!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)