Preview of pdf in a online app

Hello,

Is it possible to get a preview af a pdf in a online application?
So yes: how? Because I get the next error if I try to open a PDF with pdfViewer. openPdfFile.

Line 20:         PdfViewer pdfviewer = new PdfViewer();
Line 21: //open a Pdf file.
Line 22: pdfviewer.openPdfFile(filePath);
Best Regards

Hi,

Thank you for considering Aspose.

You can view the PDF in a web application. To show Pdf in a Web application. Please follow the following steps:

  1. Drag drop one HtmlInput control on th web form. Lets suppose:
protected System.Web.UI.HtmlControls.HtmlInputFile pdfFile;
  1. Place Image Web control on the form:
protected System.Web.UI.WebControls.Image pageImage;
  1. Now get the URL path from HtmlInputFile control. Open the file, decode its first page and then save the image to disk and then set the Image URL to the PDF Image. Please refer to the following code:
Aspose.Pdf.Kit.PdfViewer pdfViewer = new Aspose.Pdf.Kit.PdfViewer();
pdfViewer.OpenPdfFile(pdfFile.PostedFile.InputStream);

System.Drawing.Bitmap selectedPage = pdfViewer.DecodePage(0);
selectedPage.Save(Server.MapPath("page.jpeg"), ImageFormat.Jpeg);
pageImage.ImageUrl = Server.MapPath("page.jpeg");

Please note that the printing quality of the PdfViewer is not stable. We are working hard to improve it. Hope it helps.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Tks Adeel,

Works perfect but it is a bit to big :wink:
How can I save it as a smaller image.

Is it possible to show the image without saving it (on the fly ).
Example of a competitor company.
http://www.aspjpeg.com/manual_02.html#2_2

" objJpeg.SendBinary(Missing.Value);"

Kind regards
Bart


Dear Bart,

Currently we don't support sneding the image directly into web browser in our interface. But you can easily save the bitmap into a memory stream and then send it to browser.

OK tks,

How can I save it as a smaller image?

Regards Bart

Hi,

You can’t save the image in smaller size by setting arguments in Save function. You need to resize the image. Please refer to the code attached with the post.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html