Today while working with a project, I got a task to do i.e for creating dynamic PDFs of the View.
So I had started working on that and completed before time.
However , when I tried to put into the azure production environment, i got peculiar error which i had not observed in my dev Environment or in the stage.
The error I got is "The document has no pages" . I started doing research into it but unable to find any solution. At last, I thought that it might be out of memory or buffering issue, no still that is not the case. the problem arises due to inability to find the relative source path that you had provided to the image source in the view while creating the PDF with the logo or images in it.
So, before deploying to the production server be sure the following things has been checked:
1) The Image file which u have used must be existing in the website inside some folder.
2) Be sure that PDF supports few file formats such as .jpg/.bmp, so use the image of that type.
3) Don't use the image source with relative URL, it will not be able to find the image. It will work in the local but throw an error in production or staging server. So better use the live site followed with the image source.
If you are still getting the same error then just try to render some text and check whether it is rendering or not. If it is rendering then there might be some image rendering issue. Is still getting the error then just recheck your code.
Happy coding!
So I had started working on that and completed before time.
However , when I tried to put into the azure production environment, i got peculiar error which i had not observed in my dev Environment or in the stage.
The error I got is "The document has no pages" . I started doing research into it but unable to find any solution. At last, I thought that it might be out of memory or buffering issue, no still that is not the case. the problem arises due to inability to find the relative source path that you had provided to the image source in the view while creating the PDF with the logo or images in it.
So, before deploying to the production server be sure the following things has been checked:
1) The Image file which u have used must be existing in the website inside some folder.
2) Be sure that PDF supports few file formats such as .jpg/.bmp, so use the image of that type.
3) Don't use the image source with relative URL, it will not be able to find the image. It will work in the local but throw an error in production or staging server. So better use the live site followed with the image source.
If you are still getting the same error then just try to render some text and check whether it is rendering or not. If it is rendering then there might be some image rendering issue. Is still getting the error then just recheck your code.
Happy coding!
No comments:
Post a Comment