Free Support Forum - aspose.com

Can't print from web server (or even my own PC)

I just can’t seem to print pdf’s at all. You told me before to use the pdf.kit, and that worked okay on my machine (however the print dialog box appears behind all the other screens so you may never know it’s there, and there’s no way to bring it to the foreground, and it doesn’t allow page selecting), but wouldn’t work at all on the web server. I keep getting a Sys.WebForms.PageRequestManagerParserErrorException - something about Response filters and HttpModules. I even get this message on my own box when I try using just pdf as below.

Here’s my code for converting a TIF to a PDF and printing it (or trying to):

Pdf pdf1 = new Pdf();

for (int page = 0; page < xxx.PAGE_COUNT; page++)
{
//Create a section in the Pdf object …a page
Section SectionTemp = pdf1.Sections.Add();
//Create an image object in the section
Aspose.Pdf.Image Tempimage = new Aspose.Pdf.Image(SectionTemp);
//Add image object into the Paragraphs collection of the section
SectionTemp.FirstLineIndent = 0;
SectionTemp.Paragraphs.Add(Tempimage);
//Set the path of image file
Tempimage.ImageInfo.File = IVSO.ImageViewerDocumentObject.FullImagePath;
Tempimage.ImageInfo.TiffFrame = page;
//Set the type of image using ImageFileType enumeration
Tempimage.ImageInfo.ImageFileType = ImageFileType.Tiff;
//Set image title
Tempimage.ImageInfo.Title = xxx.CLIENT_NAME + ": " + xxx.CurrentDCN;
Tempimage.Margin.Left = 0;
Tempimage.Margin.Right = 0;
Tempimage.ImageScale = 0.75F;
}

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = “application/pdf”;
pdf1.Save(“Document.pdf”, SaveType.OpenInAcrobat, Response);
HttpContext.Current.ApplicationInstance.CompleteRequest();

It hangs, then fails on the pdf1.Save line.

By the way, when I could get it to print using the kit on my PC, the PDF came out in the wrong place on the page and was cut off on one side. Either I had to make the whole image smaller, which was hard to read, or settle for it being off center and about 4/5ths of a page in size.

I’m not sure what version of aspose this is - when I try to open it it says Version 1 (neutral).

Thanks!


This message was posted using Page2Forum from Aspose Demo Browser - File format components, Word, Pdf, Excel, PowerPoint component demos

Hi Larry,

The above code only generates a new PDF and then renders it to the browser. I can’t see anything related to printing. Can you please share how you’re trying to print the PDF? If you’re using PdfViewer class of Aspose.Pdf.Kit for .NET to print the PDF file then please share the code snippet you’re using at your end. Pleas also share the output PDF file which you need to send to the printer.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi,

Sorry for replying you late.

Can you please share the source image file, so that we can test the PDF generation process at our end. We apologize for your inconvenience.

Thanks for getting back to me! I’ve moved on to other problems which I’ve posted elsewhere in this forum. What I finally ended up doing with the printing was I generated the image in an HttpHandler which just looks like a browser window with nothing but the PDF image. Then the user can click on the printer icon in the browser window. That’s why you don’t see anything that looks like printing. When I didn’t hear back from you I gave up on trying to print directly from the page the user was in.

There’s a lot of code that goes into the Handler, however, the critical part that renders the image which was the last few lines of the code snippet above I changed to:

HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = “application/pdf”;
pdf1.Save(HttpContext.Current.Response.OutputStream);
HttpContext.Current.ApplicationInstance.CompleteRequest();

The line in red writes the image to the browser window (instead of trying to return it to the originator page’s window as I was doing originally).

Thanks!

I’d love to get an answer to my other question. So far 13 people have looked at it but nobody’s responded. I haven’t been able to find a solution anywhere in the forums or elsewhere.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Aspose.Pdf is a component which offers the feature to create a PDF document from scratch and you can save the resultant PDF over some physical location or display the result in user browser. I am afraid it does not provide any feature regarding the printing of PDF document.

As far as I can see from the code snippet in your first post, once the statement pdf1.Save("Document.pdf", SaveType.OpenInAcrobat, Response); is executed, you can use the Print option under File menu of user browser to accomplish the job. Else, you can try using PdfViewer class of Aspose.Pdf.Kit to print the resultant file. I am afraid the approach that you have mentioned in your previous post, is not related to Aspose.Pdf so I am afraid I might not be able to share any particular information which can resolve this issue.

We apologize for your inconvenience.