When converting HTML to PDF, the font size appears too small when printing the document

var opt = { margin: 1, filename: '1099PdfData.pdf', image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 }, jsPDF: { unit: 'in', format: a0, orientation: 'l'} };

I am utilizing these settings to convert HTML content to PDF format, but I have encountered an issue where the text appears very small when printing an AO page. Can someone provide guidance on how to increase the text size in this scenario?

Answer №1

I have successfully implemented this code snippet which can generate PDFs for multiple pages

constructor(@Inject(DOCUMENT) private doc) { }

captureScreen() {
    const element = this.doc.getElementById('content');

    html2canvas(element).then(canvas => {
      const imgWidth = 285; // setting width
      const imgHeight = canvas.height * imgWidth / canvas.width;

      const dataUrl = canvas.toDataURL('image/png')
      let pdf = new jspdf('l', 'mm', 'a4'); // configuration
      const position = 0;

      pdf.addImage(dataUrl, 'PNG', 0, position, imgWidth, imgHeight)
      pdf.save('generated.pdf'); // file name
    });
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can I take to conceal the mat-stepper header within my mat-stepper component?

I'm currently working on a project utilizing Angular-7. Within this project, I've incorporated Angular Material's mat stepper. My question pertains to hiding the header of the mat-stepper as shown in the diagram below. I prefer it not be vis ...

Concealing tab bars on Ionic 2 secondary pages

In my Ionic Bootstrap configuration, I have the following setup: { mode: 'md', tabsHideOnSubPages: true } However, despite having this setting in place, the tabs still appear on some sub-pages. It seems to be happening randomly. Is there ...

Angular 2: Applying a class to a specific element by referencing its id

I am trying to figure out how to add a class to an element with a specific id in Angular 2. In regular JavaScript, you can do it like this, but I need help translating this into Angular 2: document.getElementById("MyElement").className += " active"; Cur ...

Discovering nested trees within a tree structure in typescript

Imagine having a tree structure in JavaScript like this: a1 --b ----c1 a2 --b2 --b3 ----c2 If you needed to find c2, the path would be a2->b3->c2 Now, consider the following JSON object representing a family tree: treeFamily = { name ...

The GET API is functioning properly on Google Chrome but is experiencing issues on Internet Explorer 11

Upon launching my application, I encountered an issue with the v1/validsColumns endpoint call. It seems to be functioning properly in Chrome, but I am getting a 400 error in IE11. In IE v1/validCopyColumns?category=RFQ&columns=["ACTION_STATUS","ACTIO ...

Here's a quick tip for adding a new line in your input message in Angular - just press Shift +

I need help with my chat box input field. I want it to be able to handle new line inputs similar to Facebook's chatbox. Here is a screenshot of My Chat Box: [1]: https://i.sstatic.net/NeG7d.png My HTML code for the input field: <form class=" ...

An informative step-by-step approach to constructing Angular applications utilizing npm and TypeScript

When I first encountered Angular2, I was introduced to TypeScript, npm, and more for the very first time. I was amazed by their power, but I know I've only scratched the surface. While I can navigate through the "development mode," my ultimate goal i ...

ways to coordinate two subscriptions so that one initiates only when the other one emits

Currently, I am developing an Angular application with a specific scenario. I have an observable signal named dataFetchedEvent$, which indicates that data has been fetched from a remote location. Additionally, there is a form that relies on this remote dat ...

Mocking functions using Sinon and Asynchronous calls

I am working on a project where I have a file called mainFile that utilizes a method named helperMethod. This method, which resides in a separate file called helperFile, returns a Promise. How can I mock the output of the helperMethod? Here is the structu ...

Unit Testing JWT in Angular 2

Using JWT for authentication in my API calls. I am in the process of coding a service method. An interceptor is applied to all requests: public interceptBefore(request: InterceptedRequest): InterceptedRequest { // Modify or obtain information from ...

TS2365: The '!== 'operator is not compatible with the types ""("" and "")""

function myFunction(identifier: string) { identifier = "("; }; let identifier: string = ")"; if (identifier !== '(') throw "Expected '(' in function"; myFunction(identifier); if (identifier !== ')') throw "Expected &a ...

Guide on incorporating arrow buttons for navigation on the left and right sides within a Primeng tab view component in Angular 8

Looking to enhance navigation tabs with left and right arrows for better support of larger tab sizes in the nav menu. I attempted using Primeng since my Angular 8 application already utilizes this library. Are there any other libraries besides Angular Ma ...

Preventing page refresh with Ionic's alert controller

I'm a beginner in Ionic-Angular and I'm facing an issue with a matautocomplete feature that includes an icon. The problem arises when a value is selected in the matautocomplete, a list should be displayed below. However, when I click on the icon, ...

Limit the use of Bootstrap CSS to a single module

I've spent hours struggling with this issue. I couldn't find any online resources that address the problem I'm facing right now. :( In my current setup, I have two modules: home and admin. My home page relies on Bootstrap CSS to function pr ...

Updating the Mat Table Label Dynamically in Angular

Is there a way to dynamically change the value of a label in an Angular mat table with pagination without recreating the entire table? The goal is to update the header label without having to regenerate the whole table structure. For instance, in the tab ...

What is the best way to call an Angular component function from a global function, ensuring compatibility with IE11?

Currently, I am facing a challenge while integrating the Mastercard payment gateway api into an Angular-based application. The api requires a callback for success and error handling, which is passed through the data-error and data-success attributes of the ...

Efficient method to identify distinct keys within a collection of objects using Typescript

https://i.sstatic.net/qHkff.png I am currently developing an angular application that includes: a group of filters and data records displayed in a table The columns in the table correspond to the filters, where each filter contains unique values from it ...

Ensuring that the field remains active in Angular2 even after editing it with a value

When the 3rd dropdown value is selected in the first field dropdown, it enables the 2nd field. However, when I edit and change a different value, since the 2nd field is disabled, I receive null or undefined as the value. I want the 2nd field to retain its ...

Encountered an unhandled exception: Module 'source-map' not found while attempting to run Angular on a Raspberry Pi

I am currently developing an Angular application to run on a Raspberry Pi. However, I encountered the following error when trying to start the application: An unhandled exception occurred: Cannot find module 'source-map' Require stack: - /home/pi ...

Developing Angular components with nested routes and navigation menu

I have a unique application structure with different modules: /app /core /admin /authentication /wst The admin module is quite complex, featuring a sidebar, while the authentication module is simple with just a login screen. I want to dyn ...