PDF .NET Library Logo
Home Products Code Library Online Demos Support Forum Buy About Us  
Code Library

How to use PDFTechLib in restricted (hosting) environments.

"Pdfdocument" object constructor accepts a stream object.

You can use "response.OutputStream" to create a PDF in restricted environments.

Note:

You must upload the fonts you wish to use into an alternate directory because most hosting environments will not allow access to the Windows/Fonts directory. See this page on how this can be done: Setting an Alternate Fonts Directory

c# sample:

PDFCreationOptions opt = new PDFCreationOptions();

opt.FontDirectory = Request.PhysicalApplicationPath + "\\Fonts";

Response.Charset = "utf-8";

Response.AddHeader("Last-Modified", DateTime.Now.ToString("r"));

Response.CacheControl = "public";

Response.AddHeader("Content-Disposition", "attachment; filename=Barcode.pdf");

Response.ContentType = "application/pdf";

PDFDocument doc = new PDFDocument(Response.OutputStream, opt);

doc.CurrentPage.Body.AddText("sample text");

doc.Save();

Response.End();

Back to PDF Code Library