You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Daniel Wilson (JIRA)" <ji...@apache.org> on 2010/02/11 02:18:28 UTC

[jira] Created: (PDFBOX-615) shfill operator needs implementation

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


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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12853794#action_12853794 ] 

Andreas Lehmkühler commented on PDFBOX-615:
-------------------------------------------

I'm not an expert, but AFAIU the shfill operator, you are not that far away from the solution. The shfill operator can be used similar to the fill operator under the following terms:

- use Graphics2D.setPaint instead of Graphics2D.setColor, all needed information should be in the shading dictionary
- take the current clipping area into amount
- don't use the current path
- use the path information from the shading dictionary (AFAIU that depends on the used function??)
- if there aren't any path information in the dictionary, just use the clipping path
- the current color in the grpahics state isn't used and must not be altered

HTH

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837614#action_12837614 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

I'll note my "progress" here in hopes that if I'm way off base in the concept, one of you can throw a flag.

It does seem that there should be a class to represent a Shading Dictionary.  Conceptually it is parallel to PDPattern, so I now have a PDShading class.  I haven't committed this code as it's really not doing anything yet ... but it looks like part of the solution.

The piece I completely overlooked in last night's comment was the _sh_ operator.  I'm implementing it as o.a.p.util.operator.pagedrawer.SHFill.

At this point its process method is simply logging the argument list.

This operator is getting a single name argument -- just like the spec says it should.  In my case it's:
[COSName{Sh0}]

I must say I'm a little confused regarding how to take that name and get the Shading Dictionary.

The relevant section of the PDF file looks like this:
<</Parent 2 0 R
    /Contents 178 0 R
    /BleedBox[0.0 0.0 1152.0 1656.0]
    /PieceInfo
        <</Illustrator 142 0 R>>
    /ArtBox[39.6431 171.689 963.828 1655.02]
    /MediaBox[0.0 0.0 1152.0 1656.0]
    /Thumb 183 0 R
    /TrimBox[0.0 0.0 1152.0 1656.0]
    /Resources
        <</Shading
            <</Sh0 170 0 R>>
            /ColorSpace
                <</CS0 174 0 R/CS1 162 0 R/CS2 175 0 R/CS3 168 0 R/CS4 163 0 R/CS5 169 0 R>>
            /Font
                <</T1_0 176 0 R>>
            /ProcSet[/PDF/Text]
            /Properties
            <</MC0 158 0 R>>
            /ExtGState
                <</GS0 161 0 R>>
        >>
        /Type
        /Page
        /LastModified(D:20090602144525-05'00')
    >>

The Sh0 name is clearly there ... and it refers to object 170 if I'm reading it right.  Object 170 appears to be:
170 0 obj
<</ColorSpace 162 0 R/AntiAlias false/Coords[0.0 0.0 1.0 0.0]/Function 171 0 R/Extend[true true]/Domain[0.0 1.0]/ShadingType 2>>
endobj

This contains the required entries for a shading dictionary of ShadingType 2 (Axial) as well as a couple of the optional ones.

Which all brings me back to trying to get the Shading Dictionary from the name Sh0.

Again, pointers are MUCH appreciated.

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837056#action_12837056 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

Pages 302 - 331 of the PDF spec 1.7 describe the shading operation.

Shading is one set of the Pattern operations ... the other set being Tiling Patterns.  Those don't concern me at the moment, and we have some support for them in the org.apache.pdfbox.pdmodel.graphics.color.PDPattern class.

The set of Shading operations does gradient fills -- and there are 7 different types of these gradient fill shadings.

Now, I could use some implementation thoughts as I bring the concept back to our object model.

Since the shading operation is used for stroking & filling operations, is deriving it from PDColorSpace as was done with PDPattern the right answer?

Since there are 7 different types of shading operations, do we need 7 different classes?  

Or should the method that does the fill/stroke check the class's type and do the operation?  And ... which method is that?  PDPattern has next to no methods.  And neither do the PDColorSpace derivatives that we use frequently like PDDeviceRGB.  The only thing that really appears to matter there is createColorModel.  In the case of a shading / gradient fill, is createColorModel possibly enough?  It hardly seems it ...

Any thoughts along this line are MUCH appreciated.

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PDFBOX-615) shfill operator needs implementation

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler updated PDFBOX-615:
--------------------------------------

    Attachment: Centerplan.pdf

An other pdf example using a shading dictionary

> 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
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12854514#action_12854514 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

Thanks, Andreas, for both the pointers and the example.

That example looks much more approachable than the one from my customer!  I'll see if I can make some headway on it this week.

> 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
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Igor Podolskiy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837670#action_12837670 ] 

Igor Podolskiy commented on PDFBOX-615:
---------------------------------------

> I must say I'm a little confused regarding how to take that name and get the Shading Dictionary.

Well, the specification of the sh operator says ([PDF32000:2008], p. 182, Table 77, second paragraph) says:

"[...] [Operand] <name> is the name of a shading dictionary resource in the Shadingsubdictionary of the current resource dictionary [...]"

As far as I understand, you are supposed to do the following if you encounter an sh operator:

1. Get its operand (Sh0 in your example)
2. Look for a Shading entry in the Resources dictionary of the current page. This entry is a dictionary itself.
3. Use your sh operand value (Sh0) as the key for that dictionary. The corresponding value is the shading descriptor dictionary you use for the painting.

(Derefencing the indirect references may be needed in between, of course.)

I think the confusion arises from the fact that the spec uses the term "shading dictionary" for two different things: firstly, the entry in the page's Resources dictionary with the key /Shading, and secondly, for the thing I called "shading descriptor" here, i.e. the one with the /ShadingType etc. entries which is described in section 8.7.4.3 of the spec.

[PDF32000:2008] http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12838407#action_12838407 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

Initial code in revision 916345.
Still needs several function bodies written.

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12848871#action_12848871 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

Revision 926744 takes a big step closer.  

Currently I have only 1 example PDF that uses this operator ... and it is a very complex example.

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PDFBOX-615) shfill operator needs implementation

Posted by "Daniel Wilson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12838176#action_12838176 ] 

Daniel Wilson commented on PDFBOX-615:
--------------------------------------

Thank you, Igor.  That's getting me closer ...

> 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
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.