Free Support Forum - aspose.com

PDF Document Title

How can the PDF document title appear at the top of the browser's title bar? Normally, the title is placed between the title tags of a HTML document. A portion of the XML document which is bound to the PDF file is shown here:

<?xml version=""1.0"" encoding=""utf-8"" ?>

....

Hi,

Adding titile into PDF is supported by Aspose.Pdf but adding title into the browser’s title bar is not supported. You should write your own code outside Aspose.Pdf to display the title in browser’s title bar.

Hi Tommy,

When I wrote code outside of Aspose.Pdf, the browser title is overwritten with the filename instead of the document title whenever a PDF document is created. Using the example below, instead of getting "My Document Report" on the browser title line, a filename like "http://mywebsite/report.aspx" appears.

<html >

<head runat="server">

<title>My Document Report</title>

</head>

<body>

<form id="form1" runat="server">

<div>

</div>

</form>

</body>

</html>

Thank you.

Hi,

Aspose.Pdf uses the following code to output Pdf to browser:

response.Clear();
response.ClearContent();
response.ClearHeaders();

if(saveType == SaveType.OpenInAcrobat)
response.AddHeader(“content-disposition”,“attachment; filename=” + fileName);
else
response.AddHeader(“content-disposition”,“inline; filename=” + fileName);
response.ContentType = “application/pdf”;

response.BinaryWrite(buf);

response.Flush();
response.End();

I think this code overwrite the title. As a workaround, you can save the Pdf into stream and write the stream into browser by your self.