Click here to Skip to main content
Rate this: bad
good
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.Open();
            //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!"));
            document.Close();
        }
Posted 20-Jul-11 0:54am
Edited 20-Jul-11 0:57am
v2
Comments
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
good
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,
  Permalink  
Rate this: bad
good
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.
 
Spire.Pdf[^]
 
Spire.Doc[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2014
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