Choice and extension of the five implementation methods of Angular and PDF

 On the premise of pure web (regardless of mobile native), the functions of PDF basically include:

  • Client-side PDF: the simplest scenario, and there are many ways to implement it. Basically, there is no need to worry about it. For a simple implementation, please refer to the first article in the series.
  • Client-side PDF preview: It is necessary to consider the sharing of html templates and css styles on the normal page and the preview page. If you write two sets of the same thing, the workload for maintenance will be greater, and it is more likely to have the problem of focusing on one thing and ignoring the other, resulting in bugs. You can refer to the second article in the series.
  • Server-side PDF: The advantage is that there is no need to consider the problem of network transmission when the amount of data is large, and it can also shield the PDF rendering difference caused by different systems. In the same way, you need to consider whether you need to support previews, html templates, css styles, data source logic and binding, and you need to consider sharing between normal pages, preview pages, and server-side rendered pages. You can refer to the third and fourth articles in the series.
  • Scheduled PDF task: This requirement is relatively small, and it was not mentioned in the previous series of articles. It is not essentially different from generating PDF on the server. The only thing that needs to be considered is the permission issue. When a user initiates a PDF generation task from the client, it is sent to the server to generate a PDF, which contains the user information of the currently logged-in user. However, when the task is a scheduled task, there is no user information. A special cron task user is required to be responsible for generating PDF files.

Of course, the requirements are constantly changing. When the PDF requirements change from simple to complex, it is also a good process of code refactoring and reflection. Every family has hard-to-read scriptures, and the same is true for code implementation. I hope this series can help you better design functions and avoid detours.

おすすめ

転載: blog.csdn.net/KenkoTech/article/details/131409481