PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:58 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Fri Feb 14, 2014 3:41 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
VB.NET code:

Code:
        Using pd As PdfSharp.Pdf.PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(filePath, PdfSharp.Pdf.IO.PdfDocumentOpenMode.ReadOnly)

            For Each page As PdfSharp.Pdf.PdfPage In pd.Pages

                Dim seq As PdfSharp.Pdf.Content.Objects.CSequence

                seq = PdfSharp.Pdf.Content.ContentReader.ReadContent(page)

                // do stuff with seq

            Next

        End Using


Some PDFs work fine with the above code. But when I create a test doc with Microsoft Word 2010 and "save as" PDF, the "ReadContent" function is failing. Is this a known issue or am I doing something wrong?

Thanks for the help.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 14, 2014 4:00 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!
maxmoore14 wrote:
Is this a known issue or am I doing something wrong?
Do you get an error message (an exception)? Might help to narrow the problem down. A sample PDF could also help.

Weekend starts right now.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 14, 2014 4:14 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
Here is a link to more details:

http://stackoverflow.com/questions/2178 ... -word-2010


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 14, 2014 4:17 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
Trying to attach a sample doc for you, but the forum is giving me this error:

"The image file you tried to attach is invalid."


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 14, 2014 9:29 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
Hi!
You can attach ZIPped PDFs.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 14, 2014 9:36 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
Thanks!


Attachments:
Short test.zip [76.45 KiB]
Downloaded 1163 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 3:49 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi!

If you downloaded the source package, then you can make the changes yourself.

In file CLexer.cs locate method "public CSymbol ScanNextToken()".
Old code:
Code:
case '<':
  return this.symbol = ScanHexadecimalString();


New code:
Code:
case '<':
  if (this.nextChar == '<')
    return this.symbol = ScanDoubleBracketedEntry();
  return this.symbol = ScanHexadecimalString();


Same file, new code (e.g. to be added above "public CSymbol ScanNumber()"):
Code:
protected CSymbol ScanDoubleBracketedEntry()
{
    ClearToken();
    token.Append(currChar);

    char ch;
    while (true)
    {
        token.Append(ch = ScanNextChar());
        if (ch == '>')
        {
            token.Append(ch = ScanNextChar());
            ScanNextChar();
            return CSymbol.String;
        }
    }
}


I'm sorry for the inconvenience, but I don't know when a new version of PDFsharp will be released.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 4:30 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
Ok, that's great. Thanks very much for the help. Currently I am using the nuget package, but I just downloaded the source code like you suggested. I assume the simplest thing to do would be to leave the solution as-is and just make the changes you suggest, then re-compile. If all I am doing is PDF parsing, can I safely ignore the Charting project?


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 5:00 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
maxmoore14 wrote:
If all I am doing is PDF parsing, can I safely ignore the Charting project?
Yes, PDFsharp does not reference the charting solution.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 5:28 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
While I'm at it, any harm in bumping the target framework to 4.0?


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 17, 2014 7:29 pm 
Offline

Joined: Fri Feb 14, 2014 3:28 pm
Posts: 9
Working now. Thanks again for the help.

I have a different question, so I'm going to open a new thread now.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 133 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group