renzi Posted June 9, 2009 Share Posted June 9, 2009 I am trying to copy a PDF file, open the PDF copy, read in the first line, alter it, then write it back as the first line of the same PDF file.I can get it all to work, but the file is altered in some undesirable way and looses most of its size (from 26k original down to 1k post-run) and obviously the ability to view using acrobat.Here is what I have so far - I must be missing something simple?!? Perhaps I just don't understand enough about PDF file construct?#Include <File.au3>$Test_PDF = "E:\DIR00\D0000001.PDF"$New_PDF = "\\S3W04855\K$\_DATA_MIGRATION_PROCESSING\_NORMALIZED_\JBH_200805_STMT_01_of_02_20080605173901\DIR00\D0000001.PDF"FileCopy ($Test_PDF, $New_PDF, 9)FileSetAttrib ($New_PDF, "-R")$PDF_H = FileOpen ($New_PDF, 0)$PDF_Line01 = FileReadLine( $PDF_H, 1)MsgBox( 4096, "This is the origonal line", $PDF_Line01)$PDF_Line_NEW = ("%PDF" & StringRight ( $PDF_Line01, 5))MsgBox( 4096, "PDF Line New = ", $PDF_Line_NEW)FileClose ($PDF_H)$PDF_H = FileOpen ($New_PDF, 1)$FRTL = _FileWriteToLine ( $New_PDF, 1, $PDF_Line_NEW, 1)If $FRTL = 0 Then MsgBox(0, "Error", "Unable to write line to file: ", $New_PDF ) ExitEndIfFileClose ($PDF_H)PDF file line one:3N$FKJLK$940$MND-1.2 Desired line one:%PDF-1.2 Link to comment Share on other sites More sharing options...
evilertoaster Posted June 9, 2009 Share Posted June 9, 2009 FileReadLine is for TextFiles. You'll have a tough time getting it to work on other files types. You'll probably want to use FileRead with the file opened in binary mode . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now