Maybe sth like this:

        void FixPDF(string PathPDF)
        {
            byte[] bytes = System.IO.File.ReadAllBytes(PathPDF);

            int wynik = 0;
            for (int a = 0; a <= bytes.Length - 5; a++)
            {
                if ((bytes[a] == 37) && (bytes[a + 1] == 37) && (bytes[a +
2] == 69) && (bytes[a + 3] == 79) && (bytes[a + 4] == 70))
                    wynik = a + 5;
            }

            byte[] nowyPDF = new byte[wynik+1];
            for (int i = 0; i <= wynik; i++)
                nowyPDF[i] = bytes[i];

            System.IO.File.WriteAllBytes(PathPDF, nowyPDF);

        }

2011/5/24 Balder <[email protected]>

>  On 24/05/2011 14:09, Jaremi wrote:
>
> Remove bytes after %%EOF work very well, but there is easy way to do it
> using C#?
>
> Read the file as a normal file (not with itext), search for last appearance
> of %%EOF, remove everything after that, save the file (if you want to save
> it)
>
>
>
>
> 2011/5/24 1T3XT BVBA <[email protected]>
>
>> Op 24/05/2011 12:56, Jaremi schreef:
>> > OK. Thanks, now but i found one problem with your file.
>>  It's not MY file, it's YOUR file.
>> > Function getNumberOfPages() or getPageCount() throw exception.
>>  Of course: YOUR file is corrupt.
>> Want proof? Remove all the bytes after the final %%EOF and iText will be
>> able to process it correctly.
>> Don't blame iText for not refusing to process YOUR corrupt file.
>>
>> Note that I've already adapted iText so that it can deal with YOUR
>> corrupt file,
>> but you'll have to wait until the next release to have that fix.
>> If you want to process the file right now: fix YOUR corrupt file.
>>
>
>
> --
>
> Kind Regards
> Balder
> ------------------------------
> redlab-log <http://www.redlab.be/blog/>
> @redlabbe <http://twitter.com/redlabbe>
>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to