|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
We are getting an error "Adobe Reader could not open... because it is either not a supported file type or because the file has been damaged..." when trying to open a PDF generated by the EO tool.
Strange thing is that this works in one environment but not another.
Can some provide assistance debugging this issue?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
You can try to save the file and then open it with Adobe Reader to see if it works. If that still does not work, you can click the "Submit Test Project" link at the top of the forum to view instruction on how to send that file to us. Once we have the file we will look into it as soon as possible.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
I actually have a little more information on this. When I look at the contents of the PDF it's actually an HTML file. It's an exact html rendering of the page that is supposed to be rendering as a PDF. In fact, if I change the extension to html it opens just fine.
Any ideas why that could be happening?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
How did you create the PDF file? Do you use HtmlToPdf, ASPXToPDF or MVCToPDF?
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Yes, HtmlToPdf. Wish I could step the code but it is compiled in a production environment.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I am assuming that you are calling HTML to PDF in a web application. In that case the problem is almost certain in your code that sends the result to the client. HtmlToPdf generates a PdfDocument object. The verify whether the PdfDocument is created correctly, you can save it into a physical file and verify if that file is correct.
If that file is correct, then the next step is instead of saving it to a file, you can save it into a MemoryStream and then call that stream's ToArray method to convert it into a byte array. This byte array contains the PDF file contents. You would then need to send this file to the client. There are many reasons why this part won't work, but that would be a generic ASP.NET web programming question so you can probably search online to see if you can find the answer.
Alternatively, you can use ASPXToPDF (If your application uses Web Form) or MVCToPDF (If your application uses MVC). Those two components can send the result to the client for you.
If you still believe that it is related to us, please try to isolate the problem into a test project and send the test project to us. We will be happy to take a look once we have that.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Thanks very much for the quick response. Saving to a MemoryStream and then writing that to the response object seems to have resolved the issue.
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Here's a question, though: we also need to append a static pdf to each rendered html pdf. This worked great using the PdfDocument object and the merge method... but this doesn't seem supported using MemoryStream. Is there a workaround that you know of?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You would use this method: http://www.essentialobjects.com/doc/4/eo.pdf.pdfdocument.merge_overload_1.aspxThis Merge merges multiple PdfDocument objects into a single PdfDocument object. On the other hand, you can load/save a PdfDocument from/to a Stream object (with MemoryStream being one type of Stream object). These two things are completely unrelated to each other. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Right... but it appears we cannot use the PdfDocument object. I tried writing the merged PdfDocument to a MemoryStream and then proceeding as described above but that did not work.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, A merged PdfDocument and a "regular" PdfDocument should not be any different in term of saving them to a MemoryStream. If one works and the other doesn't, then there might be an issue somewhere in our merging feature. In that case we need you to isolate the problem into a test project and then send the test project to us in order to look further. Please see instructions on submitting test project here: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Sorry, maybe I wasn't clear - the issue is not with the merge, it's with PdfDocument.Save. That doesn't seem to be working, for either merged or unmerged documents.
I was able to successfully convert html by bypassing PdfDocument altogether, but if I do this, I can't merge. Sound like there are no other options for merging but to use PdfDocument.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
In that case you can send us a test project demonstrating the problem and we will be happy to look further. We are not aware of any conflicts between Merge and Save. Both are methods on PdfDocument class and they suppose to be able to work together.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
Sorry, I guess I'm still not making myself clear. There's no problem with merge. Merge works fine. What we can't do is save ANY PdfDocuments on one machine while it works fine everywhere else. No errors.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I am not sure if I understand exactly what you meant by "can't save ANY PdfDocument". If you meant that when you save it you get HTML instead of PDF file, then that is not possible. PdfDocument.Save saves data inside the PdfDocument into a binary block. There is no way that method can somehow magically turn up some HTML in the result it generates since a PdfDocument object has absolutely nothing to do with HTML. So in that case most likely the problem is in the code where you send the result to the client. In that case you will need to resolve that issue yourself since is sending a binary file from server to client is a generic programming topic that is unrelated to our product, so we are not in a position to troubleshoot that problem for you.
If you meant that you are getting an error while saving the PDF file (for example, an exception), then you can first give us the exception information (exception message, stack trace), we will see if we can figure out anything from that. If that does not reveal anything, we will need you to send us a repro project.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/21/2014 Posts: 9
|
All I wanted to know was whether there was a way to merge pdfs without using PdfDocument but I think I have my answer. Thanks!
|
|