PDF Viewer

Posted by: mayur.purandare on 28 August 2019, 10:15 pm EST

  • Posted 28 August 2019, 10:15 pm EST

    I have created one C1PdfDocument Object to create pdf files.
    Now I am applying different settings to C1PdfDocument object to create customized pdf file like image, digital signature etc.

    I want to view this file before creation, because to verify how file looks after applying different settings.

    I came across PDFViewer control to view pdf file but it accepts file path means only created file can be viewed in that control.
    Is there any way to show C1PdfDocument object data in that PDFViewer window without creating file.

    Or is there any control available to fulfill my requirement?
  • Replied 29 August 2019, 3:58 pm EST

    Hello,

    You can use the LoadDocument method of PDFViewer which load the Pdf from the stream. Please refer to the following documentation link:
    https://help.grapecity.com/componentone/NetHelp/c1pdfviewerwpf/webframe.html#C1.WPF.PdfViewer.4~C1.WPF.PdfViewer.C1PdfViewer~LoadDocument(Stream,String).html

    Hope it helps.

    Thanks.
  • Replied 2 September 2019, 3:17 pm EST

    Yes. I know I can do it with LoadDocument Method.
    But my query is something different.

    I want to view the file before creation. I want to view C1PdfDocument Object in PDFViewer.


  • Marked as Answer

    Replied 10 September 2019, 10:30 pm EST

    Hello,

    Sorry for the delay!

    You can load the stream into PDFViewer using LoadDocument method. Please refer to the following lines of code:

    C1PdfDocument pdf = new C1.WPF.Pdf.C1PdfDocument();
    System.Windows.Rect rect = pdf.PageRectangle;
    rect.Inflate(-72, -72);
    Font font = new Font("Arial", 12);
    pdf.DrawString("Hello World!", font,Color.FromRgb(0,0,0), rect);
    System.IO.MemoryStream ms = new System.IO.MemoryStream();
    pdf.Save(ms);
    ms.Position = 0;
    Viewer1.LoadDocument(ms);


    Also, refer to the attached sample for implementing the same.

    Thanks,
    PDfViewertest.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels