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

Tilman Hausherr commented on PDFBOX-3257:
-----------------------------------------

I had the same problem with setProducer(), so it's not just for dates.

There's a bug in XMPSchema.setTextProperty():
{code}
if (nodeList.getLength() > 0)
{
    Element node = (Element) nodeList.item(0);
    node.setNodeValue(propertyValue);
}
else
{
    Element textNode = schema.getOwnerDocument().createElement(propertyName);
    XMLUtil.setStringValue(textNode, propertyValue);
    schema.appendChild(textNode);
}
{code}
See this:
http://stackoverflow.com/a/4681358/535646
http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/Node.html#setNodeValue%28java.lang.String%29
nodeValue is always null for {{Element}} objects, so the call to setNodeValue() 
doesn't make sense.

this should be changed to
{code}
if (nodeList.getLength() > 0)
{
    Element node = (Element) nodeList.item(0);
    XMLUtil.setStringValue(node, propertyValue);
}
else
{
    Element textNode = schema.getOwnerDocument().createElement(propertyName);
    XMLUtil.setStringValue(textNode, propertyValue);
    schema.appendChild(textNode);
}
{code}

> XMPSchemaBasic setCreateDate and setModifyDate don't work in some cases
> -----------------------------------------------------------------------
>
>                 Key: PDFBOX-3257
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3257
>             Project: PDFBox
>          Issue Type: Bug
>          Components: JempBox
>    Affects Versions: 1.8.8, 1.8.11
>         Environment: Suing pdfbox from maven
>            Reporter: Svetlozar Argirov
>            Priority: Minor
>         Attachments: SJA Brochure February 2016 (DFV Edits).pdf
>
>
> When setting XMPSchemaBasic with in certain PDFs , setCreateDate and 
> setModifyDate do not work if the dates are already set in the pdf.
> So this will not work as expected:
> {code:Java}
> XMPSchemaBasic bi = xmp.getBasicSchema();
> bi.setCreateDate(someDate);
> bi.setModifyDate(anotherDate);
> {code}
> Setting other metadata fields works as expected, except for these two.
> I found a workaround . If I set the fields to null, before setting them to a 
> new value everything works as expected:
> {code:Java}
> XMPSchemaBasic bi = xmp.getBasicSchema();
> bi.setCreateDate(null);
> bi.setCreateDate(someDate);
> bi.setModifyDate(null);
> bi.setModifyDate(anotherDate);
> {code}
> But still it feels like there is something wrong with the way setting these 
> two dates work.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to