You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2015/11/09 18:22:11 UTC

[jira] [Updated] (PDFBOX-3084) More generic PDPageContentStream constructor

     [ https://issues.apache.org/jira/browse/PDFBOX-3084?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr updated PDFBOX-3084:
------------------------------------
    Attachment: EnumSet.diff

Proposed patch, with does not contain the "further" feature, only the core proposal (which is a good idea IMO). I hope this is what you had in mind; if not, please comment and/or improve :-) There's no javadoc or refactoring yet (the method is too long), and I haven't touched the existing methods.

I'm not persuaded that the "further" feature is needed.

> More generic PDPageContentStream constructor
> --------------------------------------------
>
>                 Key: PDFBOX-3084
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3084
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 1.8.10, 2.0.0
>            Reporter: Michael Klink
>         Attachments: EnumSet.diff
>
>
> h3. A missing option
> There already are numerous constructors of the {{PDPageContentStream}} class
> {code}
> public PDPageContentStream(PDDocument document, PDPage sourcePage)
> public PDPageContentStream(PDDocument document, PDPage sourcePage,
>     boolean appendContent, boolean compress)
> public PDPageContentStream(PDDocument document, PDPage sourcePage,
>     boolean appendContent, boolean compress, boolean resetContext)
> {code}
> _(focusing on *page* content streams)_
> which still fail to cover all relevant cases, foremost the case of _prepending_ a new stream to create new background material.
> Prepending a new stream has been requested by users e.g. on stackoverflow
> * [how to add background image to PDF using PDFBox?|http://stackoverflow.com/q/33406920/1729265]
> * [How to underlay a content stream with using PDPageContentStream?|http://stackoverflow.com/q/28502226/1729265]
> Furthermore PDFBox code itself internally at some places prepends a new content stream, mostly to prepend a save-graphics-state operation before the existing content.
> ----
> h3. A proposal
> To not introduce yet another explicit flag parameter, I'd propose creating a new constructor which accepts an {{EnumSet}} parameter for an enumeration of flags ({{compress}}, {{prepend}}, {{append}}, {{reset}}, ...) instead of all those flag parameters. The former constructors could then be deprecated.
> {code}
> public PDPageContentStream(PDDocument document, PDPage sourcePage,
>     EnumSet<StreamOptions> streamOptions)
> {code}
> There obviously are combinations in which some option does not make sense, e.g. {{reset}} without  {{prepend}} or {{append}}. These may either be silently ignored or rejected with some exception.
> ----
> h3. Thinking this even further
> One might even consider to make this more generic by allowing one additional parameter which may be an integer or a content stream. This constructor variant could interpret {{prepend}} and {{append}} as respectively _before_ or _after the indicated existing page content stream_.
> In this case even a {{replace}} option would make sense.
> I have not yet seen actual requests for a feature requiring this constructor variant, though.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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