Click here to Skip to main content
15,888,236 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to send a pdf file via email attachment in Outlook. There is field in pdf related to local time and the requirement is when pdf is open in user's system then time will show according to user's time zone. I created pdf using itext sharp in c#

Please help me out this.
Thanks

What I have tried:

I need to send a pdf file via email attachment in Outlook. There is field in pdf related to local time and the requirement is when pdf is open in user's system then time will show according to user's time zone. I created pdf using itext sharp in c#

Please help me out this.
Thanks
Posted
Updated 27-Dec-16 21:09pm
Comments
Kornfeld Eliyahu Peter 28-Dec-16 3:00am    
Does the client opens the PDF using an application you wrote?
Do you know the time-zone of the recipient before sending the email?
What happening if the same PDF will be opened a second time from a different time-zone?
Member 11852187 28-Dec-16 3:06am    
Thanks for your quick response!!!
1.Yes client open the pdf using applications like acrobat reader etc.
2.Nope I don't have time zone of recipient.
3. If the pdf will open in second time-zone then it will show the time according to his time-zone that means current time-zone of user.
Afzaal Ahmad Zeeshan 28-Dec-16 3:11am    
1) You did not write Acrobat Reader, which is because you have no idea how to do this.
2) Then ask for it. Otherwise, use a UTC-based time zone to support all cultures. Since you have no idea, maximum of the work will be required to be done by client, Acrobat Reader here, and for that you will require to write a plugin — if they allow so.
3) See, PDFs are portable, not dynamic document formats. To create a new document, you need to modify it, for that you need a library. Client may chose to not have that library installed on their machines.

You cannot do that on their machine, as most of them won't have the iTextSharp library installed at all, to do so, just use "UTC time", or use their locales to generate the time stamp dynamically.

In most cases, I would recommend using an HTML email, Outlook will do maximum of its own to make sure that changes are made to show the content in current locale — provided they are also using Outlook; nonetheless, most of the current email providers provide this service to find out and extract date time values for calendars etc. However, PDF would require to be modified to change the value of that paragraph or chunk, which would then require you(r user) to have a library... So on and so forth. The only "logical" solution to this is to actually use their locales, before generating the PDFs.

You can ask the users to enter their locales, or send the emails with UTC time. Users will know what time it will be on their schedule.
 
Share this answer
 
v2
Comments
Member 11852187 28-Dec-16 3:38am    
What is the programmatically way to ask user to enter his locales?
How to update time on the basis of locales in pdf?
Afzaal Ahmad Zeeshan 28-Dec-16 3:43am    
Simple, when they registered for your service — any way of service, notification etc. you asked them for their email address. You can ask them for their country, or time-zone along with that to subscribe to your paper.

That is the best way, and users won't mind that. Otherwise, on the same page you can tell them that if they don't do this, you will have to send a UTC based time stamp. To update that, you just need to add a condition (if...else block) in the iTextSharp code to add that time dynamically.
Member 11852187 28-Dec-16 4:21am    
I got your concern but it's not my requirement.
My requirement - I need to send pdf as an attachment in email but I don't have any options to register user or contact user. I have only his/her email address. And any attendees can open that email and pdf timezone will change accordingly.
Afzaal Ahmad Zeeshan 28-Dec-16 5:22am    
How did you get their email address? You might have asked them to do some registration or something. Right? If you are using some sort of bulk email sending, or bought email address, we apologize there is nothing we can do with that.

Secondly, there is another way of doing this, you can use the method in Solution 2, create the PDF yourself, and write the date that you want to add in the JavaScript. That way, it will be fine.
Member 11852187 29-Dec-16 2:13am    
Could you please suggest me some stuff for adding javascript in PDF?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900