Hi,
We have implemented Aspose.Pdf in one of our functionality to update PDF add some text and showing to user. Here we need a function/method that will ;
1. After writing the text, load same PDF in same browser's new tab(Not in new window)2. PDF opened in browser needs to show .pdf page extension in url rather than .aspx page
For your reference we have used below code,
//open document
Document pdfDocument = new Document(sr.BaseStream);
Aspose.Pdf.Page pdfPage = null;
//accept for a particular page
pdfPage = (Aspose.Pdf.Page)pdfDocument.Pages[PdfPageNumber];
//create text fragment
TextFragment textFragment = new TextFragment(textToWrite);
//set corordinate
textFragment.Position = new Position(PrintPdfXCoordinate, PrintPdfYCoordinate);
//set text properties
textFragment.TextState.FontSize = PrintPdfCouponCodeFontSize;
textFragment.TextState.BackgroundColor = System.Drawing.Color.LightBlue;
textFragment.TextState.ForegroundColor = System.Drawing.Color.Black;
textFragment.TextState.FontStyle = FontStyles.Bold;
// create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
// append the text fragment to the PDF page
textBuilder.AppendText(textFragment);
//generate new Pdf file output stream.
MemoryStream outStream = new MemoryStream();
pdfDocument.Save(outStream);
// specify the duration of time before a page,cached on a browser expires
HttpContext.Current.Response.Expires = 0;
// Specify the property to buffer the output page
HttpContext.Current.Response.Buffer = true;
// Erase any buffered HTML output
HttpContext.Current.Response.ClearContent();
//Add a new HTML header and value to the Response sent to the client
HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=output.pdf");
// Specify the HTTP content type for Response as Pdf
HttpContext.Current.Response.ContentType = "application/pdf";
// Write specified information of current HTTP output to Byte array
HttpContext.Current.Response.BinaryWrite(outStream.ToArray());
// close the output stream
outStream.Close();
HttpContext.Current.Response.End();
Can you please let us know solution for above mentioned issue ASAP ?
Thanks
Kishan