You are here:

C#/Building a PDF Viewer application

Advertisement


Question
Hello Sara,

I had contacted you earlier regarding my final yera engineering project.

Anyway, I'll recap.

My project is basically making a pdf viewer in .NET. We came across the iTextSharp library while searching online. Our first aim is to build a atand-alone application (either C# or VB.NET) that can open PDF documents. If I try to open a pdf directly through C#, it opens it up in Adobe. I do not want that. So can you suggest a way of making an application that is a simple PDF viewer. I know I will need some dll files or OCX controls.

Deciphering the iTextSharp library was very difficult. Could you suggest how to go about adding references and using libraries like iTextSharp and PDFSharp?

Thank you,
Abhaya

Answer
Hello,
download the pdfsharp.dll from this website http://sourceforge.net/projects/pdfsharp
or you can download the whole source from there
create a project , it can be web or windows not different it depends on your usage,
if you want to add the dll itself, then in your solution explorer right click on the name of your project/add reference/ browse tab/ browse pdfsharp.dll /click on ok
it has sample on that website too
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing.Layout;

  XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
               PdfPage page = document.AddPage();
               page.Width = XUnit.FromMillimeter(193.91);
               page.Height = XUnit.FromMillimeter(270.04);


               // Create graphics object and draw clock
               XGraphics gfx = XGraphics.FromPdfPage(page);
              // RenderReport(gfx);
               textdraw(gfx, page.Width, page.Height,yourdatatable or ...);

               // Send PDF to browser
               MemoryStream stream = new MemoryStream();
               document.Save(stream, false);
               Response.Clear();
               Response.ContentType = "application/pdf";
               Response.AddHeader("content-length", stream.Length.ToString());
               Response.BinaryWrite(stream.ToArray());
               Response.Flush();
               stream.Close();
               Response.End();  

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Hosnieh [Sara]

Expertise

Questions which I can answers: 1- Programming (C#.net, Vb.net, javascript, HTML) more Web applications 2- CSS 3-Databases (Ms SQL server -all versions) 4-OS (workstation and servers (windows)) 5- MS office 6- General problems in computer software I cannot answer other kinds of questions which I did not mention here.

Experience

my CV: http://iran-americamarket.com/Contact.aspx I have more than 8 years Experience in IT field. my core skills are : • Asp.net Developer (Portal, Dynamic websites ,e-commercial websites) • Visual studio.net 2003,2005,2008 (VB.net , C#.net , AJAX.net) • O.O programming (n-tier Architecture) • Database (SQL server 2000-2005, Oracle9i, Ms Access) , TSQL, Stored procedures, Triggers • IIS 5-6 , SSL (Installation and configuration SSL) , Network(TCP/IP ,Active directory , DHCP, … ), Windows 2000-2003 Server Configuration and administration • UML (usecase diagram, class diagram) , Microsoft Project • Graphics Design( Photoshop , Flash ) • JavaScript , CSS, DHTML, XML • Hardware (physical installation, configuration , and driver installation) • Ms Office all versions (Ms word, Ms Access, Ms Excel, Ms Outlook , Ms FrontPage, and etc) • OS (Windows –Linux) and VMware • Network Monitoring (Solarwinds) • Computer Teacher, English Teacher • MATLAB (simulations and computation projects)

Organizations
-

Publications
Translation Experience English to Farsi • Use brain scan to predict when people will buy products . May 2008 (Published in AI Magazine) – Medicine , AI • Totally tubular motors _Tomorrow automation technology : March 2008 (Published in AI Magazine) – AI , Mechanic, Industry • Improving PLC compatibility and function flexibility: March 2008 (Published in AI Magazine) – AI , Robotics , Industry • Make packaging lines more flexible: January 2008 (Published in AI Magazine) – AI , Robotics , Industry • Personal CNC : December 2007 (Published in AI Magazine) – AI , Medical , Industry • Multipurpose optical tools Characterize as MEMS: December 2007 (Published in AI Magazine)- optical physics • Managing Innovation: November 2007 (Published in AI Magazine) – IT Management • Calculating the total value of ownership (TVO):October 2007 (Published in San-ate Hooshmand Magazine) -IT and Economics

Education/Credentials
I am currently student and doing my Master in Computer Network Engineering

Awards and Honors
- Poster about new methods of management in Organization( Entrepreneurship ) - 2007

Past/Present Clients
-

©2012 About.com, a part of The New York Times Company. All rights reserved.