Simple PDF parser class

I started to create a simple pdf parser. See link:

https://dl.dropboxusercontent.com/u/22620793/PDF%20parser.zip

For now I only tested it on Windows. There is a simple invoice create test program included, so you can see how it is working. For the addjpg to work with the example program, copy the Xojo.jpg example file to the program directory after building the program. Or use the included compiled program.

The current beta version can create a PDF file with Text (standard fonts (Times, Helvetica, Courier and Symbols), draw a line or box and add a simple JPG file.

When I create a PDF file only contains text then It works fine in Acrobat Reader. But when I add a JPG to the PDF is opens fine in Acrobat Reader, but Acrobat asks te save the PDF. I haven’t figured out yet what causes this? Maybe someone has an idea?

Maybe someone can help to flatencode streams in Xojo? Or other addons to make it an even better Free PDF parser class.

You may want to check https://forum.xojo.com/6205-pdf-class/

Crash in the IDE (OS X 10.10.4) here:

[code] sHulp = str(pic.Width, “#”)

NilObjectException[/code]

Debugger says that pic is Nil and picFile does not exists.

I only double click in the Project and run it in Xojo (2015r1) IDE.

After building the project: same NilObjectException.

I deleted the file name in the script and drop it again from the disk: same result.

I’ve made a change in the code of PushButton1:

imagefile = app.ExecutableFile.Parent.Child("Xojo.jpg") If Not imagefile.Exists Then MsgBox "The image files does not exists" Return End If

And I get my MsgBox.

Nota: this trouble can comes from my end (I have troubles with one Post-Build Script that copies icns [icons] into the stand-alone, so…)

Coen have already made a lot of work on his own.

Good to know, but…

@Emile Schwarz
I have the same error, because the pre build copy file to application directory is not working either with my version of Xojo. After building and manualy copy the xojo.jpg it works.

@Michel Bujardet I have seen that tread, but no source is offered there. The development looks like it has stopped.

For unknow reason, it does not works anyymore. It used to work some weeks ago (same Xojo 2015r1 !!!)…

BUT DIFFERENT OS: now I use Yosemite 10.10.4.

Back at home, I will get an eye on Maverickks (or in a previously installed Yosemite < 10.10.4…)

Indeed it has stopped. I remember Dave getting stuck with pictures somewhere.

I solved the small corruption error. There was a problem with de XREF table, because of encoding problems:

I changed the following:

In the newPDF method I changed the first line in:
sPDFcontent = “%PDF-1.6” + chr(13) + chr(10) +"%"+chrB(161)+chrB(179)+chrB(197)+chrB(215)

In the OBJcreate Method:
I used + 2 instead of +4

In the PDFcreate method:

case "AO" 'All outlines
  iTel =0
   sHulp = "<<"

AND

'xref
iXREFoffset = sPDFcontent.len +2

@Dave S I used the following online tool:
http://www.pdf-online.com/osa/repair.aspx

It also creates a report of the errors. It gave me the Eureka moment for detecting the errors in my parser. Maybe you can use it to detect the error in you pdf’s too.

I got This error compelling on Xojo Mac: sHulp = str(pic.Width, “#”)
Exception: NilObjectException

Also does the same on Windows: An exception of class NilObjectException was not handled. The application must shut down