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 2014/09/17 21:48:33 UTC

[jira] [Comment Edited] (PDFBOX-2350) Type1 Parser hangs indefinitely

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

Tilman Hausherr edited comment on PDFBOX-2350 at 9/17/14 7:47 PM:
------------------------------------------------------------------

Please try also 
{code}
PDDocument.loadNonSeq(new File(pdfFilename), "");
{code}
that does the decryption if needed.

also, the correct way to decrypt with the old parser is
{code}
if( document.isEncrypted() )
            {
                try
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                    document.openProtection(sdm);
                }
                catch( InvalidPasswordException e )
                {
                    System.err.println( "Error: The document is encrypted." );
                }
            }
{code}

I'm not saying that this will solve your problems but it is worth a try.

If it still doesn't work, please change the code so that parseBinary() saves the "decrypted" byte array into a file (below line 448), and attach that file here.

{code}
FileOutputStream fos  = new FileOutputStream(new File("font-" + System.currentTimeMillis() + ".txt"));
fos.write(decrypted);
fos.close();
{code}
Unless that font is also confidential :-(

Other things to try if you are using windows: download and use qpdf to uncompress the file and see if there are any error messages.

qpdf --stream-data=uncompress file.pdf fileU.pdf


was (Author: tilman):
Please try also 
{code}
PDDocument.loadNonSeq(new File(pdfFilename), "");
{code}
that does the decryption if needed.

also, the correct way to decrypt with the old parser is
{code}
if( document.isEncrypted() )
            {
                try
                {
                    StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
                    document.openProtection(sdm);
                }
                catch( InvalidPasswordException e )
                {
                    System.err.println( "Error: The document is encrypted." );
                }
            }
{code}

I'm not saying that this will solve your problems but it is worth a try.

If it still doesn't work, please save the "decrypt" byte array (in the ParseBinary nethod) in a file and post it here.

> Type1 Parser hangs indefinitely
> -------------------------------
>
>                 Key: PDFBOX-2350
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2350
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 2.0.0
>         Environment: Windows 7, JDK 1.7.0_51-b13
>            Reporter: Daniel Scheibe
>
> When rendering the first page of my pdf document the Type1Parser (org.apache.fontbox.type1.Type1Parser) hangs in a loop in 
> {{parseBinary(byte[] bytes) throws IOException}}
> and "kills" our rendering pipeline. Please find the loop that hangs below:
>         // find /Private dict
>         while (!lexer.peekToken().getText().equals("Private"))
>         {
>             lexer.nextToken();
>         }
> There is no token named "Private" ever in the list of returned tokens (they're empty all the time).  
> Furthermore going deeper into the source code it seems the class reading the tokens (Type1Lexer) does never finally advance the buffer position and always returns an empty name token in the readToken(Token prevToken) method.
> Looking at the decrypted buffer i cannot get something useful out of it based on my current understanding.
> Unfortunately i cannot provide the pdf in question as it contains confidental data.
> Acrobat Reader XI Version 11.0.08 renders the document just fine.
> In addition it seems the pdf was encrypted (40-Bit RC4) with an empty password and says it's pdf version 1.5.
> Does this provide enough information or can i do anything else to help nailing this one down?
> I guess this might be a pdf document structure/feature that is not yet supported completely but at least pdfbox should throw an exception instead of failing "silently"...



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