Yes, you certainly can. You don't use the relative paths. However, you can get the physical path from a relative path using Server.MapPath method in asp.net or something equivalent in other platforms.
Printable View
Hello Stanav,
First of all thanks for your valuable post. It helped me a lot in few fuzzy things.
I am using the itextsharp 5.1.1.0 dll version along with your PDFManipulation2.vb code.
I want to remove restrictions of the PDF File which has 128 bit AES encryption. But i only have user password & do not have owner password.
For that i tried your method named "RemoveRestrictions" but it's throwing exception stating "Bad User Password". So could you please help me in this ?
Thanks in advance...
================
Stanav,
Thanks for your reply. I tried the same steps mentioned by you. But still its giving "Bad User Password" when i am passing the User password , not the Owner password, as my requirements are to remove restrictions with user password not owner password.
Your help in achieving same will be great.
Thanks in advance....
It should work with user password. I've tried it myself.
Can you upload a sample password protected pdf and give me the user password?
It could be the version of iTextSharp you're using (5.1.1.0). I was testing it using the older version 5.0.2.0.
Dear Stanav,
Thanks for your valuable reply.
Yes i tried & it worked.I was doing some mistake earlier.
But thanks a ton to you for your valuable support.
Also i am stuck in some other dot net setup problem as mentioned below. Can you share your update in same if possible ?
i have 1 .net windows application & same needs to be distributed so for that i had made setup & deployment project that has created 3 files as below.
a) MSI installer file.
b) Setup file.
c) dotnetfx30 file as dotnet is prerequisite & required this application to work so it needs to be installed
first.
Target Area is to have single .Exe file instead of above 3 files. How can we accomplish this ?
Please help...
Thank you stanav, itextsharp.dll ver. 5.1.2.0 works great with your class PdfManipulation2.vb
at first atempt without any problem. So, is there any way to donate you?
Dear Stanav,
Thanks for your valuable post that you have shared on this forum.
I have one scenario where your input is highly required i.e. i have tried your valuable code for removing the PDF restrictions whereas the encryption level were of 128 Bit Aes type with itextsharp dll version 4.0.3 & it worked awesome.
But when i am trying to remove pdf restrictions where the encryption type is 256 Bit aes then it throwing error & getting failed in removing restrictions.
Can you please help me in this ?
Thanks in advance.
==================================================
Hi, Friends
I am new to this forum please help me with my problem both source and output pdf files are attached please help me producing the output file as i have more than 500 pages in one source file and more than 20 pdf files.
Its Very urgent
- Thanks in Advance
Thanks for reply
but please let me know about some technique which can help me doing so please.. help me i don't want u to do the coding but u can post some techniques which can help
thanks in advance
Based on the sample pdf files you posted, there is no easy way you can split the source file to get the output you want. You are trying to split the data in 1 pdf page into several pages. To do this, you will need to read the source file data (if possible) and the create new output pdf files on the fly.
Dear Stanav,
Thanks for the valuable post that helped me in my projects.
I need 1 more input from your side i.e. the way out for removing the PDF file
restrictions which is encrypted with 256 bit encryption with user and/or owner password.
Really looking for your expert reply on this.
thanks n regards....
RkTech
==========================================================
Oh, really? I didn't know that. I'm still on 5.0.2 (no immediate need to upgrade yet).
I still wonder though, if that is the case as you said 5.1.1 supports 256 AES then why wouldn't it work? Have you tried using UTF-8 encoder to convert the password to bytes array and then passing it to the constructor of the pdfreader class? In my code, I was using the system default encoder, which might not be UTF8 in other regions.
Hi stanav,
Thank you for this information. It has been very helpful.
Can the SplitPdfByParts method split a single sheet into 4 seperate sheets by dividing the original sheet into 4 equal quadrants? What I mean by this is down the middle horizontally and vertically.
Thanks.
It's much easier to do it the other way around (merging 4 pages into 1 page);)
As for your question, it depends on what kind of data you have in the source pdf page. If you can somehow extract the data from the page, you can then can use that data to create 4 new pages in a new pdf document.
Thank you for your quick reply. I have multi page pdf's where some of the pages look like the example provided. I need to split those 4 blocks off into individual sheets.
Thanks for the help.
Yes Stanav 5.1.1 supports 256 bit AES. As i treat you as an expert in this PDF subject so it would be great if you try your encoding permutation & combinations in same, as i do have less knowledge in same area.
Also please lemme know in case of any input or discussion.
Thanks....
Take Care..
============
I downloaded the newest version of itextsharp 5.1.3 to try out and I can't seem to find any evidence of it supporting AES_256 encryption. If you look at all the encryption constants in the PdfEncryption class, there are only 3: standard_encryption_40, standard_encryption_128 and aes_128. If it supported aes 256, I should've seen the declaration of aes_256 constant.
Can you provide some links/source where it is confirmed that aes_256 is supported?
Dear RkTech,
After I saw your mentioning of PdfWriter.ENCRYPTION_AES_256 constant, I took a closer look at the PdfReader class source code and you're right, it does support AES256. According to Adobe's PDF specification, it uses a new algorithm, 3.2a, to compute the encryption key. This algorithm uses the 1st 127 bytes from an utf-8 password (anything longer gets truncated) + 8 bytes salt + 48 bytes U string and then computes the aes-256 hash of the result to be used as the password bytes array...
Anyway, I'd give it a try if you can provide me a sample aes-256 password protected pdf.
Happy Holidays.....
Dear RkTech,
I've made some changes to the PdfManipulation2 class and it now supports opening pdf files with AES-256 password protection. Please download the new version and try it out.
Happy Holidays.
Stanav.
Hi, every one i want to write a program in VB .NET for find the invalid / unreferenced Keys in Registry and fix them please any one tell me the technique by which i can do this stuff or any one can feel free to provide me the Little code
Thanks in Advance
Hey Stan,
I have an access database that creates a PDF report. In this report each page is a separate invoice. Each invoice is the same layout only the data on the pages differ. What i'd like to do is take this PDF report and split each invoice into it's own separate pdf file. Is this something i can use what you have provided us with to do? If so do you have any suggestions on what i can use to complete this.
Thanks very much for you time!
If all the invoices are in the same format (same number of pages) and you know before hand how many pages each individual rinvoice should have, you can use the PdfManipulation2.SplitPdfByPages method which can be found in the PdfManipulation2 class. On the other hand, if the number of pages in each invoice differs, as long as you know the number of pages for each of them, you can modify the above mentioned method a little to have it split the pdf the way you want (it tough to find out how many pages each invoice has though).
Best luck.
Hi stanav and thank you for your work
I want to connect to an encrypted pdf (with digital certificate).
Can you post a sample of how to do it?
Thank you!
Hi All,
I was wondering if any of you can help me out with my problem - I am calling iTextSharp from VB .Net windows form to create PDF report.
Ho can I -
1. Create multiple headers(header1, header 2 etc, logo)
2. Multiple footers - Page X of Y, some other text etc.
3. Positioning data on PDF from SQL Server.
I would really appreciate if any kind soul can give me some direction or code sample.
Thanks in advance.
StanMan
I'm using PdfManipulation2 with iTextSharp 5.2 and it appears that ExtractPdfPage() may have a significant bug.
When I perform the following operations on a 3 page document with each page containing a single TIF image (such as a 3-page fax converted to PDF):
PdfManipulation2.ExtractPdfPage("c:\temp\test.pdf", 1, "c:\temp\test1.pdf")
PdfManipulation2.ExtractPdfPage("c:\temp\test.pdf", 2, "c:\temp\test2.pdf")
PdfManipulation2.ExtractPdfPage("c:\temp\test.pdf", 3, "c:\temp\test3.pdf")
then...
test1.pdf will be approx 1/3 the size of test.pdf
test2.pdf will be approx 2/3 the size of test.pdf
test3.pdf will be just shy of the full size of test.pdf
When viewed in a PDF viewer, each extracted document will show the proper single page and nothing else. Everything looks fine.
If i open up test3.pdf and look for the /CCITTFAXDECODE entries, I find 3 of them, one for each page of the original PDF.
Based on these results, it appears that the ExtractPdfPage function (or the iTextSharp code that it uses) is failing to remove vestiges of the pages which precede the extracted page -- specifically the images they contain.
Is this bug happening for anyone else? If so, does anyone know how to fix it?
Just used the code for a post over at the MS Social Forums, works like a charm.
Hey Stanav
I am first time working on PDF documents.I was searching on Rotation of a PDF page. I got some code samples regarding rotations by 90,180,270,360 degrees.
But my problem is that if there is a very small rotation required of the order of few degrees .....
Is there any way that we can specify an angle using a slider bar or use the mouse to click and rotate the PDF page...
Thanks in Advance
Regards
Aryan
PDF Manipulation2 is a nice bundle Class, Kindly include the PFX signing function which could add one more feather to the class.
SunilMogan
I'm getting confused really bad on this :
All i need to do is get the bookmarks and the pdf file names they point to.
all of the bookmarks point to other pdf files which should be on the HD.however i've noticed that at the time i downloaded these files some of the files they were supposed have were not on the server..or i didn't download em or something..
so now i have 100's of files with missing pdf's..too many to go thru and correct manually.
So i thought that i could extract the bookmarks and the files they point to..then take those file names add the web address for each one(all located on the same server) and make a download list.
So i did this
i get errors saying this is not declared so i searched thru the itextSharp zip file and found the ones that were missing..and those started saying this was missing ,that was missing ,this wasn't declared,,it never ended..Code:Option Explicit On
Public Class Form1
'Specified the path to the source pdf file
Dim sourcePdf As String = "E:\pdfs\1.pdf"
'save as XML file
Dim outputXML As String = "E:\1.xml"
Public Shared Function ExportBookmarksToXML(ByVal sourcePdf As String, ByVal outputXML As String) As Boolean
Dim result As Boolean = False
Try
Dim reader As New iTextSharp.text.pdf.PdfReader(sourcePdf)
Dim bookmarks As System.Collections.Generic.List(Of System.Collections.Generic.Dictionary(Of String, Object)) = SimpleBookmark.GetBookmark(reader)
Using outFile As New IO.StreamWriter(outputXML)
SimpleBookmark.ExportToXML(bookmarks, outFile, "ISO8859-1", True)
End Using
reader.Close()
result = True
Catch ex As Exception
Throw New ApplicationException(ex.Message, ex)
End Try
Return result
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ExportBookmarksToXML(sourcePdf, outputXML)
End Sub
End Class
it was like i needed to have every single one of those class files in my project??
I had to convert those to vb.net tho..luckily i found a bulk converter which worked online.
So i'm gonna have to ask if someone could PLEASE tell me how i can fix this so i can get it to do what i need it to..i'm going around in circles here,,, or even better still, put all the subs that i need into one module file for me.
Thanks
well at the time i posted this i didnt know there was a dll hehe i was trying to add all the source code into the project..but now that i've added the .dll it's working good..how can i export to a txt file tho..not xml?
Different question about this ..
is it possible to use this to edit bookmarks..
so if my main pdf file has bookmarks to say \1.pdf, \2.pdf. \3.pdf etc,..
and i wanted to put the bookmarked files into a separate folder instead of having them in with the main pdf file..can i alter the bookmarks to reflect the new directory where they can be found.
like \temp\1.pdf
????
thanks for the info,,,I'll check into that