loading a PDF

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  loading a PDF

DynamicPDF CoreSuite for .NET (v5) Forum

 Aug 13 2008 8:40 AM
I am trying to load a PDF I just created and saved to a network location into a web browser.
I implemented some impersonation so I have valid credentials, my code finds the PDF, but it fails to load it says that the document has no pages.

ceTeDoc = New ceTe.DynamicPDF.Document
impersonateValidUser(user, domain, pass)
ceTeDoc.DrawToWeb(sFileName, True)
undoImpersonation()
Response.End()

I need to be able to load the PDF back into the page in order to print/save it. Any other methods available?

Sorry if this was brought up before, I couldn't find a different thread on the issue.

Thanks for your time!
 Aug 13 2008 9:12 AM
Posted by a ceTe Software moderator
Hello,

The error you are getting is because you are not adding any pages to the document object. This is not related to validating the user. In your code you have created the "ceTeDoc" document object and then you are using the DrawToWeb method without adding any pages to the document. You will have to add some pages to the document. Following is some sample code for this.

   ceTeDoc = New ceTe.DynamicPDF.Document
   Dim page as New Page()
   ceTeDoc.Pages.Add( page )
   ceTeDoc.DrawToWeb()

If you want to display some existing PDF which is located in the server then you will have to use the MergeDocument object which takes the file path as a parameter.

   Dim document as New MergeDocument( "PDF file path" )
   document.DrawToWeb()

Thanks,
ceTe Software Support Team.
 Apr 22 2020 1:30 PM
can we create a pdf and place at some location.

if please i see code snippet.
 Apr 23 2020 10:26 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can save generated PDF to disk by specifying the output PDF file path using Draw method. A code sample is below. Please refer to the documentation on different ways to output a  PDF here.

documentObj.Draw(@"Output PDF file path");

Thanks,
ceTe Software Support Team
 Apr 23 2020 10:45 AM
can we post HtmlHELPER object to dynamicpdf to  create a  pdf ?

because previouly we used itextsharp. Now we are migrating to DynamicPdf.

below is code. Appreciate your help.

 StringReader sr = new StringReader(sb.ToString());
                        Document pdfDoc = new Document(PageSize.A4, 5f, 5f, 10f, 0f);
                        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                      
                        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                        PdfWriter.GetInstance(pdfDoc, new FileStream(filename, FileMode.Create));
                        pdfDoc.Open();
                        htmlparser.Parse(sr);
                        pdfDoc.Close();
                        Response.ContentType = "application/pdf";
                        //Response.AddHeader("content-disposition", "attachment;filename=DocumentUpload.pdf");
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
 Apr 23 2020 1:06 PM
Posted by a ceTe Software moderator
Hello,

If you are looking to create a PDF using HTML text or an HTML file, this feature is included in v10 of DynamicPDF Generator for .NET. You will need to use HtmlArea page element to do this. Please refer to the documentation on HtmlArea page element here.

You can download a fully functional evaluation edition of DynamicPDF Generator for .NET from Nuget (product ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 7:03 AM.