Click here to Skip to main content
11,410,750 members (63,522 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: PDF
hi here i return my code for creation on pdf file. but it is showing error

my code:
public void pdf()
            int i = 0;
            // r is for random file names...
            Random r = new Random();
            i = r.Next(1, 999999999);
            string filename = i.ToString() + ".pdf";
            //path where to save...
            string path = "D:/Test/" + filename;     
            Document document = new Document();
            PdfWriter writer;
            writer = PdfWriter.GetInstance(document, new FileStream(path, System.IO.FileMode.Create));
            // Set password ...replace mypass with your password .......
            writer.SetEncryption(PdfWriter.STRENGTH128BITS, "mypass", null, PdfWriter.AllowCopy);
            //document as many properties .. for time begin i am using only one ..
            //document.add is to add contant to your file..
            document.Add(new Paragraph("This document is Top Secret!"));
Posted 20-Jul-11 0:54am
Edited 20-Jul-11 0:57am
OriginalGriff at 20-Jul-11 5:58am
And what error is it showing?
walterhevedeich at 20-Jul-11 5:59am
This document is Top Secret! :laugh:
Sorry but I can't resist.
OriginalGriff at 20-Jul-11 6:15am
Damn! I was hoping he'd post the document instead of the error message! :laugh:
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you use an external library, at least tell us what it is. Your best bet is to read the docs and ask on the forums for the product you;re using,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I recommed you use Spire.Pdf/Spire.Doc to do so. Besides that, it's very easy to use and support conversion from doc, xls, html, xml, etc. to pdf.



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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,918
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100