Welcome Guest Search | Active Topics | Sign In | Register

Starting a print for a PDF converted by EO.PDF. Options
Spoon
Posted: Friday, August 10, 2012 1:30:29 PM
Rank: Newbie
Groups: Member

Joined: 8/10/2012
Posts: 1
I've converted HTML+CSS to a PDF using EO.PDF, and I have it streamed to the browser. Once loaded, I'm trying to get Adobes print dialog to pop up. I've had it working with Aspose.Words for a while, but can't full convert to EO.PDF without this working.

Code I'm trying:
Code: C#
var htmlContent = passedInHtmlVar + "<script type=\"text/javascript\">var pp = getPrintParams(); pp.interactive = pp.constants.interactionLevel.full; print(pp);</script>";
Response.ContentType = "application/pdf";
EO.Pdf.HtmlToPdf.ConvertHtml(htmlContent, Response.OutputStream);
Response.End();


This renders the PDF perfectly, but the print dialog never shows. To see if the javascript was working, I added some JS to modify parts of the document, and the modifications worked great leaving me confused to the problems with the script.

Code for Aspose.Words that works:
Code: C#
var fileName = String.Format("{0}{1}.pdf", AppDomain.CurrentDomain.BaseDirectory, fileName);
using(var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
{
    var doc = new Document(htmlStream);
    doc.Save(outStream, SaveFormat.Pdf);
}
byte[] content;
using(var ms = new MemoryStream())
{
    var pdf = new PdfReader(fileName);
    var stamper = new PdfStamper(pdf, ms);
    var writer = stamper.Writer;
    writer.AddJavaScript("var kk = getPrintParams(); kk.interactive = kk.constants.interactionLevel.full; print(kk);");
    stamper.Close();
    content = ms.ToArray();
}
if (File.Exists(fileName))
{
    File.Delete(fileName);
}
Response.ContentType = "application/pdf";
Response.BinaryWrite(content);
Response.End();


I've searched the forums, and documentation; I can't seem to figure out the mistake I'm making here. Hopefully someone can point out the issue, since I would prefer to swap to EO.PDF as it has far superior conversion results as far as I can tell.

Thanks.
eo_support
Posted: Friday, August 10, 2012 1:42:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Currently we do not have the ability to add script code directly into the PDF file. Can you send us a sample working PDF file so that we can look into it and see if we can add it? We will PM you as to where to send the file.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.