[VB.NET] Extract Pages and Split Pdf Files Using iTextSharp - Page 4-VBForums
Page 4 of 4 FirstFirst 1234
Results 121 to 129 of 129

Thread: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

  1. #121
    New Member
    Join Date
    Oct 2012
    Posts
    3

    removing restrictions

    I know this thread is a little old but I am hoping to get some help !

    I need to remove the restrictions from a PDF that is automatically generated from one of our systems. The software generating the PDF also generates a random 7 character password as the owner password which changes for each file. The user password is blank.

    I need to be able to change the files metadata to allow our PDF store to index the documents appropriately.

    If i use the restrictions remover in pdfmaniupation2.vb ( a great bit of code btw) then it does not remove the owner password, but does change all the permissions listed to allowed (apart from page extraction)

    When I use my code to change the metadata I get an exception "PdfReader not opened with owner password"

    my reading of the code in pdfmanipulation2.vb is that it should create a new PDf with the contents of the old, but it should have no encryption and have no restrictions - have I got this wrong ?, can anyone advise a better way of doing this ?

    thanks

  2. #122

    Thread Starter
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,238

    Re: removing restrictions

    Quote Originally Posted by doug_ecg View Post
    ....................
    my reading of the code in pdfmanipulation2.vb is that it should create a new PDf with the contents of the old, but it should have no encryption and have no restrictions - have I got this wrong ?, can anyone advise a better way of doing this ?

    thanks
    Yes, you got the wrong idea... Removing restrictions means just that. It won't remove the passwords.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #123
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Re: removing restrictions

    Quote Originally Posted by stanav View Post
    Yes, you got the wrong idea... Removing restrictions means just that. It won't remove the passwords.
    Ah indeed !

    Do you by any chance know of a way to alter the metadata without using the owner password ?

    With restrictions removed is it possible to copy the contents to a new PDF ?

    Thanks for your assistance !

    B

  4. #124

    Thread Starter
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,238

    Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

    Print it to a new PDF using a PDF print driver such as CutePDF... The printed version of the file (reads "new copy") won't have any passwords.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #125
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

    Thanks - that does work, I was rather hoping to handle it all within my application.

    Essentially I need to alter the document, add new metadata and then save it again. Rather irritatingly the company that produces the other piece of kit that generates the PDFs appears to use a random owner password ( and doesnt wish to change their software just so we can index the pdfs in ours)

    Does anyone by any chance know of a way to achieve this ?, if not I guess I shall have to get cutepdf, capture the created file and then work with that.

  6. #126

    Thread Starter
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,238

    Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

    Quote Originally Posted by doug_ecg View Post
    Thanks - that does work, I was rather hoping to handle it all within my application.

    Essentially I need to alter the document, add new metadata and then save it again. Rather irritatingly the company that produces the other piece of kit that generates the PDFs appears to use a random owner password ( and doesnt wish to change their software just so we can index the pdfs in ours)

    Does anyone by any chance know of a way to achieve this ?, if not I guess I shall have to get cutepdf, capture the created file and then work with that.
    The custom version of Pdf Writer (reads "paid version") allows you to bypass the "save as" dialog window and thus you can silently print to pdf from your app.
    More info can be found from their web site:
    http://www.cutepdf.com/Solutions/pdfwriter.asp

    Truly, if this is for bussiness, the one time $500 price tag of the "Custom PDF Writer with programmatic access" package is justifiable.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #127
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,593

    Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

    Stanav ... your AddWatermarkText function requires both a source file and a destination file. Is it possible to rewrite this function to require only one file? In your current function, using the same file for both source & destination results in an error. I just want to specify a filename and the watermark text & have the function add the text to that file. Is this possible?

  8. #128

    Thread Starter
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,238

    Re: [VB.NET] Extract Pages and Split Pdf Files Using iTextSharp

    You have the source code and thus you can see how it works. If it doesn't meet your needs, feel free to modify it the way you want...
    Whenever you edir a pdf file, it has to be saved as a new file due to 2 reasons: 1. pdf files are not designed to be editable. 2. The source pdf file is being opened (since you're using it to edit), and thus the file is locked. You can't delete it until the file is closed. Now that you know this, it should be fairly straight forward to modify the existing code to do what you want... That is, instead of passing in a output file path, you declare this variable locally and generate a random temporary file name for it. When done adding the watermarks, after closing the original file, you delete it and move the temp file to replace the original file.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  9. #129
    New Member
    Join Date
    Dec 2013
    Posts
    1

    Re: [VB.NET] Pdf Manipulation Class Using iTextSharp

    Stanav,

    Great help in my project. Just running into a couple of small errors and wondered if you could point me right direction in fixing them.

    Error 1 Value of type '1-dimensional array of Byte' cannot be converted to 'iTextSharp.text.pdf.RandomAccessFileOrArray'. C:\VB.Net\PDFMerge_Window\PDFMerge_Console\PdfManipulation2.vb 138 65 PDFMerge_Window

    Error 2 'MessageBox' is not declared. It may be inaccessible due to its protection level. C:\VB.Net\PDFMerge_Window\PDFMerge_Console\PdfManipulation2.vb 179 13 PDFMerge_Window

Page 4 of 4 FirstFirst 1234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.