[
https://issues.apache.org/jira/browse/PDFBOX-5149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17561834#comment-17561834
]
Emmeran Seehuber commented on PDFBOX-5149:
------------------------------------------
Looks good to me. It may make sense to make to make cloneForNewDocument
generic. Would save some casts. And of course public again. I.e. I would like
to have this patch applied:
{code:java}
--- a/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java
+++ b/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFCloneUtility.java
@@ -39,7 +39,7 @@ import org.apache.pdfbox.pdmodel.common.COSObjectable;
* Utility class used to clone PDF objects. It keeps track of objects it has
already cloned.
*
*/
-class PDFCloneUtility
+public class PDFCloneUtility
{
private static final Log LOG = LogFactory.getLog(PDFCloneUtility.class);
@@ -77,7 +77,8 @@ class PDFCloneUtility
* @return the cloned instance of the base object
* @throws IOException if an I/O error occurs
*/
- COSBase cloneForNewDocument(COSBase base) throws IOException
+ @SuppressWarnings("unchecked")
+ public <TCOSBase extends COSBase> TCOSBase cloneForNewDocument(TCOSBase
base) throws IOException
{
if (base == null)
{
@@ -87,7 +88,7 @@ class PDFCloneUtility
if (retval != null)
{
// we are done, it has already been converted.
- return retval;
+ return (TCOSBase)retval;
}
if (clonedValues.contains(base))
{
@@ -97,7 +98,7 @@ class PDFCloneUtility
retval = cloneCOSBaseForNewDocument((COSBase)base);
clonedVersion.put(base, retval);
clonedValues.add(retval);
- return retval;
+ return (TCOSBase)retval;
}
{code}
No idea regarding the MergeUtility. I don't use that directly. (And regarding
merging ContentStream COSStream: I had to learn the hard way, that you can only
place ContentStreams of Pages in an array. It is not allowed for XForms. PDFBox
incorrectly just accepts that, but Acrobat etc. doesn't really like that...)
> 3.0.0-RC1: PDFCloneUtility is no longer accessible
> --------------------------------------------------
>
> Key: PDFBOX-5149
> URL: https://issues.apache.org/jira/browse/PDFBOX-5149
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 3.0.0 PDFBox
> Reporter: Emmeran Seehuber
> Assignee: Andreas Lehmkühler
> Priority: Major
>
> PDFCloneUtility is no longer accessible by default. This is low level
> functionality, which is sometimes required and useful. PDFBox itself is low
> level, so I don't see why you would restrict access to this. Also this API is
> not really complicated nor unstable.
> For now I did a dirty workaround to access it (see
> [here|https://github.com/rototor/pdfbox-graphics2d/commit/5986bc653f83b2c06e5218ac906b9a9bc75f724e#diff-2113e77a03390c0cf920587a642fe7693e5b3c8402de783223035a79e13c2209R1]).
> I would rather like to get rid of this workaround soon.
> Other than that, PDFBox-Graphics2d seems to work fine with PDFBox 3.0.0-RC1.
> I just released a 3.0.0-RC1 version of it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]