|
Rank: Newbie Groups: Member
Joined: 1/17/2014 Posts: 4
|
Hi I am currently trying to add multiple pages from an MVC application to a PDF file. So far I have tried using the EO.Pdf.HtmlToPdf.ConvertUrl function, but that only shows the MVC login page. I have also tried implementing the MVCToPDF.RenderAsPDF(); using the attribute on the Action. This generates a PDF for that page, but it also then shows that page.
What I need is a way to add two different MVC pages into a PDF document. The users want the output from multiple pages in a PDF. I also then want the result not to be shown, but to be saved and to then send them to a different page. Is this possible?
I would consider using the merge function, but I need a way to just auto generate both PDF to then be merged. This cannot be a multistage process for the user, it needs to be generated on the fly when they click a button on a different page.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
It is always going to be one web page -> one PDF unless you do it separately and then do a merge. So if you want your PDF file to contain two web pages without merge, you have to feed it a web page that "contains two web pages". So basically you would need to create another web page that contains the contents of both pages and then convert that page instead. You can convert the page as it loads (as oppose to on postback) so it is not necessary for user to explicitly load that page into the browser.
It is also possible for you to use EO.Pdf.HtmlToPdf.ConvertUrl. However if you do that you will need to attach your authentication cookie through HtmlToPdf.Options.Cookies in order to pass the authentication process (otherwise you will hit the login page). That would not be an issue if you handles the login and creates the authentication cookies yourself. If you do not, then it's easier for you to create an additional web page.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2014 Posts: 4
|
Thank you for the quick reply.
I went ahead and tried using the authentication cookie, and adding it to the options, that did get me past the login page. I am able to call EO.Pdf.HtmlToPdf.ConvertUrl twice with two different URL's and pass in the same document. Thank you for your help.
Now it seems the library does not use the @media print css, so the overflow is hidden and I need it to be visible. I will have to somehow fix this. But that is a different issue.
Thanks, Jonathan
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Glad to hear that. EO.Pdf HTML to PDF converter does not recognize @media print CSS because most users want the PDF output to be exactly as it appears on the screen. As such we always use screen media.
Please feel free to let us know if you have any more questions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2014 Posts: 4
|
While I agree, what I am trying to do is print whats on the screen, what I actually want is to print all of the content, not just the visible portion. So when the content flows off of the screen and the scroll bar is bar is present, all I am seeing is the visible content and an image of the scroll bar. This cannot be what a user actually wants in their PDF.
I used this library on a non-MVC application and got all of the data and no scroll bar, so I am not sure why this is different. I probably have something in my css.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
It probably has something to do with your CSS. There is no different from the HTML to PDF converter point of view as to whether you use MVC or not. Internally it just convert HTML to PDF. Whether you use MVC affects how the input HTML is generated, but does not affect how they are converted.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2014 Posts: 4
|
It seems it does not see the css from the Site.css file. I took one of the classes and added it to the object on the view page with inline style="styling here" and it then seemed to work. In this case it was: text-align: center; vertical-align: middle; color: red; font-weight: 600; font-size: 18px;
Is this normal behavior?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
It should take all the CSS files. You can try to put some other simple CSS rules in your CSS file (such as "body { background-color: red; }") and see if it picks it up. If it does not pick it up, then you will want to check your IIS log to see if it indeed has requested the CSS file. If it does pick it up, then it has to be something else. You may also want to open the page with Google Chrome browser and see if it renders correctly. Different browser can render the same thing differently and our rendering is most close to Google Chrome.
Thanks!
|
|