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

Tilman Hausherr commented on PDFBOX-4445:
-----------------------------------------

Please create a separate issue for the fileoffset problem, and explain what 
happened and if possible attach the file. That is a parsing issue and not a 
merge issue.

The ViewerPreferences and DocumentInformation problem should be handled in 
appendDocument(). For people who call appendDocument() only. The language 
should be done independently from the documentinformation. I also don't see a 
reason to call setDisplayDocTitle unless one of the two has it set to true. The 
best would be to do some merge of ViewerPreferences.

I'll look at this later, so don't go on vacation for a few days...

> Need fix accessibility issue
> ----------------------------
>
>                 Key: PDFBOX-4445
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4445
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: DerekLiu
>            Priority: Major
>
> Using Adobe Acrobat Pro DC to check the accessibility issue, it reported that:
> Primary language      Failed  Text language is specified
> Title Failed  Document title is showing in title bar
> So we may need change the code to support it pass, could you please fix this?
> {code}
>  .../java/org/apache/pdfbox/multipdf/PDFMergerUtility.java | 15 
> +++++++++++++++
>  .../main/java/org/apache/pdfbox/pdfparser/COSParser.java  |  3 +++
>  2 files changed, 18 insertions(+)
> diff --git 
> a/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java 
> b/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
> index b0474f2b9..be01d32c9 100644
> --- a/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
> +++ b/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
> @@ -72,6 +72,7 @@ import 
> org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocume
>  import 
> org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
>  import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
>  import org.apache.pdfbox.pdmodel.interactive.form.PDField;
> +import 
> org.apache.pdfbox.pdmodel.interactive.viewerpreferences.PDViewerPreferences;
>  
>  /**
>   * This class will take a list of pdf documents and merge them, saving the
> @@ -422,12 +423,26 @@ public class PDFMergerUtility
>                      }
>                      tobeclosed.add(sourceDoc);
>                      appendDocument(destination, sourceDoc);
> +          
> +                    if ( destinationDocumentInformation == null && 
> sourceDoc.getDocumentInformation() != null ) {
> +                      destinationDocumentInformation = 
> sourceDoc.getDocumentInformation();
> +                      destination.getDocumentCatalog().setLanguage( 
> sourceDoc.getDocumentCatalog().getLanguage() );
> +                    }
>                  }
>                  
>                  // optionally set meta data
>                  if (destinationDocumentInformation != null)
>                  {
>                      
> destination.setDocumentInformation(destinationDocumentInformation);
> +                    if ( destinationDocumentInformation.getTitle() != null ) 
> {
> +                      if ( 
> destination.getDocumentCatalog().getViewerPreferences() == null ) {
> +                        
> destination.getDocumentCatalog().setViewerPreferences( new 
> PDViewerPreferences( new COSDictionary() ) );
> +                      }
> +                      
> destination.getDocumentCatalog().getViewerPreferences().setDisplayDocTitle( 
> true );
> +                    }
> +                    if ( 
> destinationDocumentInformation.getCOSObject().getString( COSName.LANG ) != 
> null ) {
> +                      destination.getDocumentCatalog().setLanguage( 
> destinationDocumentInformation.getCOSObject().getString( COSName.LANG ) );
> +                    }
>                  }
>                  if (destinationMetadata != null)
>                  {
> diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java 
> b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
> index 8ca955ed2..b2b28b258 100644
> --- a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
> +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
> @@ -721,6 +721,9 @@ public class COSParser extends BaseParser
>                                      }
>                                  }
>  
> +                                if( fileOffset == null ) {
> +                                  continue;
> +                                }
>                                  List<COSObject> stmObjects = 
> objToBeParsed.get(fileOffset);
>                                  if (stmObjects == null)
>                                  {
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to