Explore all Document Editor open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Document Editor

pdf.js

v2.12.313

pdfmake

0.3.0-beta.2

dompdf

Dompdf 1.2.1

pdfkit

v0.12.0

PHPWord

Popular Libraries in Document Editor

pdf.js

by mozilla doticonjavascriptdoticon

star image 37682 doticonApache-2.0

PDF Reader in JavaScript

ReLaXed

by RelaxedJS doticonjavascriptdoticon

star image 11616 doticonISC

Create PDF documents using web technologies

wkhtmltopdf

by wkhtmltopdf doticonc++doticon

star image 11434 doticonLGPL-3.0

Convert HTML to PDF using Webkit (QtWebKit)

pdfmake

by bpampuch doticonjavascriptdoticon

star image 10022 doticonNOASSERTION

Client/server side PDF printing in pure JavaScript

pdf2htmlEX

by coolwanglu doticonhtmldoticon

star image 9214 doticonNOASSERTION

Convert PDF to HTML without losing text or format.

dompdf

by dompdf doticonphpdoticon

star image 8720 doticonLGPL-2.1

HTML to PDF converter for PHP

pdfkit

by foliojs doticonjavascriptdoticon

star image 7270 doticonMIT

A JavaScript PDF generation library for Node and the browser

AndroidPdfViewer

by barteksc doticonjavadoticon

star image 6713 doticonApache-2.0

Android view for displaying PDFs rendered with PdfiumAndroid

url-to-pdf-api

by alvarcarto doticonhtmldoticon

star image 6560 doticonMIT

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.

Trending New libraries in Document Editor

borb

by jorisschellekens doticonpythondoticon

star image 2582 doticonNOASSERTION

borb is a library for reading, creating and manipulating PDF files in python.

dangerzone

by firstlookmedia doticonpythondoticon

star image 1400 doticonMIT

Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs

falsisign

by edouardklein doticonshelldoticon

star image 842 doticon

For bureaucratic reasons, a colleague of mine had to print, sign, scan and send by email a high number of pages. To save trees, ink, time, and to stick it to the bureaucrats, I wrote this script.

pdf-editor

by ShizukuIchi doticonjavascriptdoticon

star image 502 doticonMIT

Offline PDF editor. Add images, signatures, text to PDF in your browser. 🚀

scanyourpdf

by baicunko doticonpythondoticon

star image 447 doticonMIT

Repository for the Scan Your Pdf community

ptext-release

by jorisschellekens doticonpythondoticon

star image 350 doticonNOASSERTION

pText is a library for reading, creating and manipulating PDF files in python.

notebook-as-pdf

by betatim doticonjupyter notebookdoticon

star image 323 doticonBSD-3-Clause

Save Jupyter Notebooks as PDF

Text-file-to-handwritten-pdf-file

by sharanya02 doticonpythondoticon

star image 307 doticonMIT

Converts a text file to a handwritten pdf file.

Simpdf

by shashanoid doticonjavascriptdoticon

star image 237 doticon

Simple PDF text editor

Top Authors in Document Editor

1

jsreport

16 Libraries

star icon80

2

PDFTron

15 Libraries

star icon221

3

itext

14 Libraries

star icon5206

4

tecnickcom

7 Libraries

star icon4245

5

mkl-public

7 Libraries

star icon105

6

hmcts

5 Libraries

star icon15

7

OpenConext-Attic

5 Libraries

star icon14

8

aspose-pdf-cloud

5 Libraries

star icon21

9

prawnpdf

5 Libraries

star icon4408

10

yob

5 Libraries

star icon1708

1

16 Libraries

star icon80

2

15 Libraries

star icon221

3

14 Libraries

star icon5206

4

7 Libraries

star icon4245

5

7 Libraries

star icon105

6

5 Libraries

star icon15

7

5 Libraries

star icon14

8

5 Libraries

star icon21

9

5 Libraries

star icon4408

10

5 Libraries

star icon1708

Trending Kits in Document Editor

There are numerous libraries in Java that enable working with document files. An extensive and well-liked Java library is XDocReport. 


A Java package called XDocReport enables you to create reports from documents in various formats, including Microsoft Word, OpenOffice, and others. It can be used to generate reports using information from many different sources, such as databases and XML files. The library enables the ability to add styles, graphics, and other formatting choices to the resultant reports. Popular Java frameworks like Apache POI, Freemarker, and Velocity can be coupled with XDocReport to offer a strong and adaptable solution for producing reports in your Java-based applications. 


Here is an example of how to convert a docx file to a pdf file using XDocReport in Java: 


Fig 1: Preview of the output that you will get on running this code from your IDE

Code


  1. Copy the code using the "Copy" button above, and paste it in a Java file in your IDE.
  2. Add dependent library or download the dependent jar and add in your IDE class path.
  3. replace the file name in the variables- docPath and pdfPath
  4. Run the file to convert docx to pdf file.


I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.


I found this code snippet by searching for "convert docx to pdf in java" in kandi. You can try any such use case!

Development Libraries


You can add the dependent library in your gradle or maven files. you can get the dependancy xml in above link.


You can search for any dependent library on kandi like XDocReport 

Environment Tested


I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created in open-jdk-11.0.8.
  2. The solution is tested on XDocReport 2.0.4 version.


Using this solution, we are able to convert an file using the XDocReport library in Java with simple steps. This process also facilities an easy to use, hassle free method to create a hands-on working version of code which would help us convert docx to pdf file in Java.


Support


  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

Here are some of the famous React PDF Viewer Libraries. React PDF Viewer Libraries can be used in Education, Business, Healthcare, Legal, and Government for various purposes. 


React PDF viewer libraries allow developers to display PDF files within a React application. These libraries provide features such as page selection, links, bookmarks, search, annotations, and support for various document formats. 


Let us have a look at some React PDF viewer libraries in detail. 

pdf.js 

  • Does not rely on any third-party libraries or plugins. 
  • Supports text search and navigation, text selection, text rotation, and more. 
  • Supports PDF annotations, including highlighting, drawing, and note taking. 

react-pdf 

  • Built using a lightweight virtual DOM and aims to provide fast rendering performance. 
  • Support for multiple languages. 
  • Supports the ability to add annotations. 

react-pdf-viewer 

  • Has features like text selection, page navigation, full-text search, and thumbnail previews. 
  • Supports many file formats, such as PDF, EPUB, PPTX, and more. 
  • Has a fully customizable toolbar with buttons for zooming, printing, downloading, and more. 

react-pdf-highlighter 

  • Support for undo/redo functionality for annotations and comments. 
  • Ability to export annotations and comments as text. 
  • Support for multiple selection modes, including text, area, and paragraph selections.

react-pdf-js 

  • Enhanced security. 
  • High-quality rendering. 
  • Cross-platform support. 

reactjs-pdf-reader 

  • Allows users to jump directly to a page from a table of contents. 
  • Features thumbnail view of pages and supports page navigation. 
  • Allows users to add bookmarks and annotations to a PDF. 

react-pdf-render 

  • Has an easy-to-use interface, allowing users to quickly and easily view PDF documents. 
  • Allows interactive features like page navigation, text search, and page zooming. 
  • Provides fast loading times and smooth page transitions. 

FAQ:

1. Is it possible to use Create React App to create a new PDF document?  

Create React App (CRA) is primarily designed for creating web applications using React. Although it's not designed to make PDFs, you can still use it to build a web tool. This tool can generate PDFs or make a form that collects and turns data into a PDF.


Here is how you might approach it:  

  1. Collect Data in a Form: Create a React component using the Create React App. It allows users to input the necessary data for your PDF document. It could be text, images, or any other relevant information.  
  2. Generate PDF Content: Use a third-party library to generate the content for your PDF.  
  3. Display or Download PDF: Once you generate the PDF, you can offer users the option to display or download it. You can use standard React components and HTML elements for this purpose.  

  

2. What is the Document component, and how does it work when using React-PDF?  

The 'Document' component is important for displaying PDF documents in React apps. It allows you to define the structure of the PDF document you want to display. It includes its pages and content. It stores the PDF document and helps organize and display the contents.  


Here is how the 'document' component works when using 'react-pdf':  

  • Installation and import:  First, you should install the 'react-pdf' library in your project. You can do this using a package manager like yarn or npm. Next, import the required components from the library in your React component.  
  • Usage of the 'Document' component:  You use the 'Document' component to define the structure of the PDF document. It accepts a 'file' prop which specifies the PDF URL you want to render. You can also use 'onLoadSuccess' and 'onLoadError' to handle loading events.  
  • Using 'Page' and other components:  Inside the 'Document' component, you define individual pages using the 'Page' component. Each 'page' component displays the content that should be on that page. You can include various elements within a 'Page' like 'Images or 'Text.'  
  • Rendering the PDF:  Finally, you can render the 'PDFViewer' component within your application. The 'react-pdf' library will display the PDF document according to your defined structure.  


PDF.js makes it easier to display PDFs in browsers with its 'Document,' 'Page,' and other parts. They offer a convenient way to work with PDF documents. You can make PDF views that are dynamic and interactive in your React apps.  

  

3. Can any other related React components use the Document component?  

The 'react-pdf' library offers React components that work with the 'Document' component. These components help you create advanced PDF views in your React app. These components allow you to add various types of content to your PDF documents.


Here are some of the key components:  

  • 'Page' Component:  It represents an individual page within the PDF document. You can use it to organize and structure the content of each page.  
  • 'Text' Component:  It allows you to add text content to your PDF. You can customize font sizes, alignment, color, and styles.  
  • 'Link' Component:  It allows you to create hyperlinks within your PDF document. These links can navigate to other pages within the same document or external URLs.  
  • 'Image' Component:  It will embed images within your PDF document. You can specify the source URL, dimensions, and other properties.  
  • 'Canvas' Component:  It lets you draw custom content directly onto the PDF page, like shapes and graphics.  
  • 'Layer' Component:  It allows you to create layers within your PDF document. You can use layers to show or hide specific content based on user interactions.  
  • 'Outline' Component:  It represents an outline or table of contents for your PDF document. It allows users to navigate to specific sections of the document.  
  • 'Viewer' Component:  It wraps up the 'Document' component. You can use it to control how the PDF viewer looks and works.  
  • 'Note' Component:  It enables you to add annotations or notes to your PDF pages. These notes can be interactive and provide additional information.  
  • 'Font' Component:  It provides the option to use custom fonts in your PDF document. It allows you to maintain consistent typography with your application's design.  

  

4. Where will you find its output folder after creating a document file?  

The PDF isn't saved to your computer when you use the 'react-pdf' library in a React app. Instead, the browser shows the PDF content within the React app. The application generates the PDF dynamically. It is not saved to a file on the server or the client's local machine by default.  


Here is how it works:  

  • Dynamic Rendering:   If you use the 'react-pdf' library, the PDF document becomes a group of React components. It represents the document's structure and content.  
  • No Physical Output:  The PDF appears in the browser without making a physical file. The application's JavaScript and the browser's rendering engine control the PDF content.  
  • Browser Display:  A viewer inside the user's browser shows the PDF content. Users can view the PDF document without downloading or using external software.  

  

5. When should I use jsPdf or pdfMake instead of just React-PDF?  

Both 'react-pdf' and external libraries like 'pdfMake' and 'jsPDF' serve different purposes. You can use it in different scenarios based on your requirements.


Here is when you might consider using an external library in addition to or instead of 'react-pdf':  

  • Complex PDF Generation:  Suppose you want to make custom PDFs with unique designs and interactive features. You can use graphs, tables, and charts for the features. If you want, you can use external libraries like 'jsPDF' or 'pdfMake.' These libraries offer fine-grained control over PDF content creation and layout.  
  • Server-Side Generation:   An external library might be preferable if you need to generate PDFs on the server side. You can create PDFs in various locations, such as web browsers and servers. You can do this by using libraries like jsPDF and pdfMake.  
  • Client-Side Interactivity:   If you need to add interactive elements to a PDF, such as forms or digital signatures, react-pdf won't work. It would help if you considered using a library like jsPDF or pdfMake.  
  • Custom Layouts and Components:   External libraries often provide better support for custom layouts and components. If you want more design choices for your PDF with react-pdf, you can use another library to customize it.  
  • Existing Integration:   If you already use a library like jsPDF or pdfMake, it's wise to keep using it for PDFs.  
  • Performance Considerations:   One library may perform better than another library, depending on how you use it. When choosing a library, compare how fast it renders and how much memory it uses. Find one that fits your needs.  
  • Community and Documentation:   Libraries such as jsPDF and pdfMake have been around for a long time. They have a large community and well-established documentation. If the features of an external library better match your needs, it's a good reason to choose it.  


To summarize, react-pdf is good for displaying PDF content in a React app. You can create PDFs with interactive features using libraries like jsPDF and pdfMake. They provide more flexibility and customization options. Think about what your project needs and the abilities of each library before you decide.

Angular PDF viewer library comprises open-source components. It can build and render PDF viewer components within the framework of an application. This library allows developers to integrate the functionality of PDF viewing into applications. It offers an easy way to view documents in an online environment. The library is popular among developers because it is feature-rich. It provides a consistent API and can integrate into existing projects. It is a useful tool. It offers an intuitive user experience, allowing users to view PDFs with minimal effort.  

Different features that are available in an Angular pdf viewer library are:  

  • Display PDFs:  

The ability to view PDF documents is the one feature an Angular PDF viewer library should have.  

  • Zoom in and out:  

A library should allow users to zoom in and out on specific sections of the PDF document.  

  • Document preview:  

It should offer a quick preview of the document before it's loaded into the library.  

  • Text search:  

Searching through the PDF document for specific words or phrases should be possible.  

  • Page Navigation:  

It should be easy to navigate between pages statically or dynamically.  

  • Annotations:  

Annotations should allow users to make notes about the document without changing it.  

  • Table of contents:  

A table of contents should be available so users can navigate the document.  

  • Multi-page view:  

An Angular PDF viewer library should allow users to view many document pages.  

  • PDF manipulation tools:  

The library should offer various manipulation tools. It supports tools like text highlighting, drawing, and image editing.  

Some tips for using an Angular pdf viewer library are: 

Importing a PDF File:  

  • Install the ng2-pdf-viewer library using npm.  
  • Create an instance of PdfViewerComponent, and the Url can be set to pass the PDF file you want to show.  
  • Use the set-show-all-pages option in the library to ensure it displays all the pages in the PDF file.  

Saving a PDF File to the Library:  

  • You can use the library's save options to save the PDF file to the library.  
  • To save the PDF, use the library's save method, which accepts a URL as input and saves the PDF file in the same directory.  
  • You can customize the save directory path by changing the configuration settings.  
  • You can also use the library's export feature to export the PDF file in a different format, such as .pdf, .jpg, and .png.  

To use an Angular pdf viewer library most effectively:  

  • Read the documentation to get acquainted with all the PDF viewer library features. Depending on your library, some features might be better than others. Some may have limitations and certain requirements for working.  
  • Start by exploring the different user interface features and how they work together. Pay attention to the navigation buttons. It allows you to move between different pages, rotate a page, zoom in and out, and search for text.  
  • Pay attention to the viewer's zoom ratio settings. You can make the text in the document easier to read by increasing the zoom level. You can also make the document fit the screen better by decreasing the zoom.  
  • Test out how you can navigate between different documents in the library. Some PDF viewers can store many documents and navigate between them.  
  • Use the annotations and highlighting features. These tools allow you to mark and comment on different parts of the document. This is particularly useful when collaborating on the same PDF document with others.  

Benefits:  

  • Easy to Implement:  

Angular PDF viewer libraries provide an easy-to-implementation process. It is possible to embed a PDF viewer and other content into an Angular application with a few lines of code.  

  • Robust:  

Unlike browser PDF plugins, a PDF viewer library provides powerful features and tools. It can handle more complex documents. Features like zoom, scrolling, text search, bookmarks, and annotations. It can be incorporated into an Angular application.  

  • Accessibility:  

An Angular PDF viewer library allows documents to be better accessible. It is presented in a more understandable way for users with visual disabilities.  

  • Security:  

Angular PDF viewer libraries offer improved security features like encryption and access management.  

  • Customization:  

With the ability to style and customize PDF viewers, it is possible to add branding to the PDF viewer. This can benefit organizations that need to present documents in a certain way.  

Conclusion  

Angular PDF viewer libraries are a great way. It helps add robust and feature-rich PDF viewing capabilities to any Angular project. They are easy to implement. It can be customized to support many formats and languages. They are supported by browsers, making them accessible and integrated into any application. The features offered by these libraries are extensive and can be tailored to fit any requirements. Thus, they should be considered if you want to add a PDF viewer to your Angular project.  

 

Here are some of the Angular pdf viewer libraries.  

pdf-reader  

  • Supports many file formats, including PDF, ePUB, Mobipocket Reader, and Docx.  
  • Allows you to create and view comments and annotations on PDF documents.  
  • It provides you with password protection options to keep your PDF documents secure.  

ng2-pdf-viewer  

  • Support for viewing and embedding both local and remote PDF documents.  
  • Ability to print a PDF document from the Angular application.  
  • Accessibility for impaired users using the Adobe Screen Reader.  

pdfAnnonate  

  • Its community edition is open-source and free to use.  
  • It can integrate with any existing application and system.  
  • It can export annotated documents to either PDF or images for easy archiving.  

ngx-extended-pdf-viewer  

  • Users can also upload documents from a URL.  
  • The library is designed to be mobile-friendly.  
  • Designed with SEO-friendly markup all 'in the box'. 

angular-pdf-viewer  

  • Allows developers to integrate third-party APIs for analytics, search, and document editing.  
  • Leverages the capabilities of server-side computing. It helps process the document on the server/cloud. It results in low latency and fast load times.'  
  • Provides built-in configuration options to customize and optimize its PDF rendering.  

ng2-pdfjs-viewer  

  • Allows to zoom in and out of a PDF document. It makes it easier to view detailed information or broader context.  
  • It offers text search functionality, making finding specific information within a document easier.  
  • Supports all the major browsers, like Firefox, Safari, Chrome, and Internet Explorer. 

angular-pdfjs-viewer  

  • No external dependencies.  
  • Fullscreen and zoom render.  
  • Native Angular UI components.  

FAQ  

What is an Angular PDF, and what are its advantages?  

Angular PDF is a library created by the Angular Team. It helps display Portable Document Format (PDF) documents within the Angular framework. It has many advantages, like being easy to use. It can have no extra library dependencies and support the most popular browsers. It offers downloading PDFs, printing, navigation, viewing PDFs inline, text highlighting, and annotations. Angular PDF helps developers to create interactive PDF documents. You can do it with silky-smooth page transitions and embedded media.  

 

How do you create a PDF viewer component in an Angular application?  

  • Install the ng2-pdf-viewer package with npm.  
  • Import the PdfViewerModule from the package into the app.module.ts file.  
  • Display the PDF Viewer component in the component HTML template where required.  
  • Pass the link to the PDF that's to be viewed to the PDF Viewer component.  
  • Use the optional parameters (i.e., show all or only part of the PDF) available in the ng2-pdf-viewer package.  
  • When the user interacts with the PDF, handle the event in the component TypeScript file.  


Is there any native PDF viewer for Angular applications?  

No, there is no native PDF viewer for Angular applications. It would help to use a third-party library to view PDF documents in an Angular application.  

 

Can I view a local PDF file stored on my computer using the angular pdf viewer library?  

No, the angular pdf viewer library is designed to view PDF documents stored on a remote server. It does not support local files.  

 

What is JavaScript PDF Viewer, and how does it work with Angular applications?  

JavaScript PDF Viewer is a library. It enables web developers to display PDFs in their Angular apps. It uses a PDF rendering engine such as PDF.js to render the PDFs as PNG images. It provides API calls for necessary events. It includes events like page changes, text selection, and bookmark navigation. It is customizable and works on both mobile and desktop applications.  

 

Can I open protected PDF files using the angular pdf viewer library?  

No, it is impossible to open protected PDF files using the angular pdf viewer library. This library is used to open and display PDF files. But it provides no tools for decrypting and opening protected PDF files.  

 

Are any configurable viewers available with the angular pdf viewer library?  

A few configurable viewers are available with the angular pdf viewer library. For example, PDF.js viewer by Mozilla, PDFPKG viewer, and PDF Viewer for Angular v6.0+. PDF.js viewer provides a wide range of viewing options. It allows you to customize the PDF viewer according to your needs. PDFPKG is another configurable viewer with several options. It helps in customizing the viewer's layout and designs. Finally, PDF Viewer for Angular v6.0+ is a versatile viewer. It offers various options, such as zooming and scrolling. No matter which viewer you choose, these viewers will ensure you can customize. It helps meet your specific requirements.  

 

What is a powerful PDF library that works well with Angular applications?  

The powerful PDF library that works well with Angular applications is PDF.js. This solution enables developers to render, manipulate, and annotate PDF files within applications. PDF.js provides navigation, printing, page rendering, and text selection features. It features an extensible API. It enables developers to create custom annotations and interactions with PDF documents.  

 

Does the HTML file need to be changed using the angular pdf viewer library?  

No, using the Angular PDF viewer library does not need to change an HTML file. The PDF viewer library is an Angular component. It can be included in an existing HTML file to add the PDF viewing functionality. 

Node.js is a powerful runtime environment. It helps developers to run JavaScript on the server side. It provides a vast ecosystem of modules and libraries. It facilitates various tasks, including PDF generation. One similar use case is the creation of PDF documents using node.js and PDF generation libraries.  

  

Node.js is a versatile platform that enables server-side JavaScript execution. It provides access to PDF generation modules like PDFKit, jsPDF, and Puppeteer.  

  

PDFKit is a JavaScript PDF generation library. It offers a high-level API for creating PDF documents. It provides text formatting, image embedding, metadata management, and security options. It makes it suitable for generating invoices, reports, and printable documents.  

  

jsPDF is another popular PDF generation library for node.js. It allows converting HTML or plain text into PDF files. It supports various customization options, including page layout, fonts, and image embedding. It helps to generate complex documents or convert HTML templates to PDFs.  

  

Puppeteer is built on the headless Chrome browser. It enables the generation of PDFs from web pages or HTML content. It supports capturing screenshots, emulating user interactions, and printing to PDF. It makes it valuable for generating PDF reports or converting web pages to PDF format.  

  

Using these libraries, developers can create PDF documents by defining the document structure. Then by adding content like text, images, and tables. You can apply custom styling using HTML or a dedicated API.  

  

Node.js and the PDF generation libraries provide seamless integration with other modules. It allows data incorporation into the PDF from databases, APIs, and user inputs.  

  

These libraries support file formats, including HTML, Markdown, or custom markup languages. It provides developers flexibility in generating PDFs from different sources.  

  

We can integrate these libraries into projects using npm, the package manager. You can add the desired library as a dependency in the project's package.json file.  

  

These libraries leverage the power of modern browsers, DevTools Protocol, and headless Chrome. It provides robust PDF generation capabilities.  

  

When using PDF generation libraries, developers can use the vast node.js ecosystem. It includes Webpack or Browserify for bundling and optimizing the PDF generation code.  

  

In conclusion, node.js and PDF generation libraries provide developers with powerful tools. It helps create PDF documents programmatically. Whether generating reports or converting HTML to PDF, these libraries offer flexibility. They also offer customization options and seamless integration. It makes them valuable for developers seeking PDF generation capabilities.  

puppeteer:  

  • Leveraging the headless Chrome browser, Puppeteer enables the generation of PDFs.  
  • It helps render dynamic web content, including JavaScript-based interactivity. 
  • It supports capturing screenshots and generating PDFs from HTML templates.  

jsPDF:  

  • With an API, jsPDF allows PDF creation in browser or server-side environments.  
  • It supports text, images, and basic formatting. 
  • It makes it ideal for generating simple reports, forms, or certificates.  

pdfkit:

  • This powerful and flexible library helps in generating PDF documents with content types. 
  • It supports complex layouts, custom fonts, and encryption. 
  • It makes it suitable for creating reports, invoices, and marketing materials.  

pdf-lib:  

  • This library provides various functionalities for creating and modifying PDF documents.  
  • It supports merging PDF files, adding annotations, extracting text, and signing PDFs. 
  • It enables the creation of complex and interactive documents.  

hummusRecipe:  

  • Designed for high-performance PDF generation, HummusJS allows direct manipulation of PDF files.  
  • It offers features like adding images, text, annotations, merging, splitting, and encrypting PDFs.  
  • It is suitable for scenarios that need low-level control over PDF creation.  

phantom-pdf:  

  • As a versatile PDF library, PhantomPDF supports both server-side and client-side PDF generation.  
  • It provides extensive features, including document conversion, form filling, and PDF manipulation. 
  • It helps cater use cases such as generating contracts, agreements, or legal documents.  

fpdf:  

  • FPDF is a lightweight and efficient library. 
  • It helps generate PDF documents in PHP, with Node.js ports available.  
  • It offers text and image support for scenarios requiring generating receipts or certificates.  

pdfshift-node:  

  • PDFShift is another cloud-based PDF generation service. 
  • It converts HTML or web pages into PDF documents.  
  • It supports dynamic content, JavaScript execution, and CSS styling. It enables the generation of PDFs from web content, reports, or online documentation.  

FAQ 

1. What is a JavaScript PDF, and which Node library can generate it?  

A JavaScript PDF is a PDF document generated using JavaScript code. One popular Node library for generating JavaScript PDFs is PDFKit.  

  

2. How does Vitepress create HTML documents, Markdown files, and HTML templates?  

Vitepress utilizes this library to create HTML documents, Markdown files, and HTML templates. It leverages its capabilities to convert the provided content into PDF format.  

  

3. Which are the most popular PDF libraries for Nodejs pdf generator library?  

Some popular PDF libraries include PDFKit, jsPDF, and Puppeteer. These libraries offer various features, customization options, and support for generating PDF documents.  

  

4. How do I use a Node library to convert an HTML document into a printable document?  

To convert an HTML document into a printable document, you can use libraries like PDFKit. These libraries allow you to define the document's structure. It helps add content from the HTML document and generate a printable PDF output.  

  

5. Is an invoice generator compatible with the Nodejs pdf generator library?  

Yes, there are invoice generators compatible with Node.js pdf generator libraries. Libraries provide the necessary features and flexibility to generate invoices programmatically. Developers can define the invoice's structure and content. They use the library's capabilities to generate the PDF output.  

  

6. Can we use HTML templates with the Nodejs pdf generator library?  

Yes, we can use HTML templates can with Node.js pdf generator libraries. We can customize these templates and filled with data to generate PDF documents. Some libraries support the integration of HTML templates. It allows developers to generate PDFs with predefined layouts and styles.  

  

7. Can we convert Markdown files into PDFs using the Nodejs pdf generator library?  

Yes, we convert Markdown files into PDFs using Node.js pdf generator libraries. Some libraries help parse Markdown files and convert them into PDF format. Developers can define the styling, layout, and content based on the Markdown input. 

Several types of react pdf viewers are available on the market. It ranges from lightweight components to comprehensive libraries. Some libraries offer open-source solutions, while others provide features for a paid license. When considering react pdf viewers, weighing each option's pros and cons is important.  

  

When choosing a react pdf viewer, look for a user-friendly interface. It allows easy navigation and interaction with PDFs. It supports various devices, such as desktop and mobile. Additionally, ensure that the viewer is compatible with modern browsers.  

  

React pdf viewers come with a range of features. It helps specific sections of the PDF. Some provide annotation tools that enable users to highlight, underline, or add comments. Security features like digital signatures and password security may also be available.  

  

To create and edit PDFs using react pdf viewers, start loading an existing PDF file or creating a new one. You can then use the provided APIs or component wrappers to add text, images, and annotations to the PDF.  

  

Protecting react pdf files is crucial to prevent unauthorized access. Use password protection, encryption, or watermarking features to react pdf viewer library.  

  

When writing about react pdf viewers, cover their key features. Also, work on customization options and performance across different devices and browsers. You should also specify use cases they excel, like large-scale document management. 

  

In conclusion, react pdf viewers offer a powerful solution. It helps in displaying, creating, and editing PDFs within React applications. They offer extensive features, compatibility, and ease of use. It will make them a valuable tool from document viewing to management systems.  

pdf.js:  

  • This library supports rendering PDF files in a browser environment.  
  • It helps display PDF documents in a web application. 
  • It supports features like text search, annotations, and page thumbnails. 
  • It helps enhance the user's ability to interact and navigate through PDF content.  

react-pdf:  

  • This library helps in rendering PDF documents in React applications.  
  • It supports various features like zooming, page navigation, and text selection. 
  • It provides users with an interactive PDF viewing experience within the application.  

react-pdf-viewer:  

  • This library offers a feature-rich PDF viewer component for React applications.  
  • It supports page navigation, text search, annotations, and a customizable toolbar. 
  • It provides users with a comprehensive PDF viewing experience and empowers developers. 
  • It helps create robust PDF viewer applications.  

react-pdf-js:  

  • This library provides a React wrapper for PDF.js.  
  • It helps in enabling developers to integrate PDF viewing capabilities into their applications.  
  • It supports rendering PDF files, customizing viewer options, and handling user interactions. 
  • It will make displaying and interacting with PDF documents easier in a React environment.  

react-pdf-highlighter:  

  • This library supports adding highlight annotations to PDF documents in React applications.  
  • It helps in enhancing the reading and reviewing experience.  
  • It allows users to highlight important sections, add comments, and navigate between highlights. 
  • It will enable collaboration and document analysis.  

react-pdf-reader:  

  • This library supports rendering PDF documents as images or canvases in React applications.  
  • It helps display PDF content by converting pages into images or canvases. 
  • It will enable developers to create performant and responsive PDF viewer components.  

react-pdf-renderer:  

  • This library supports rendering PDF documents as images or SVG elements in applications.  
  • It helps convert PDF pages into image or SVG formats.  
  • It allows developers to display PDF content and is compatible with different browsers.  

react-pdf-js-infinite:  

  • This library extends react-pdf-js by adding infinite scrolling capabilities to the PDF viewer.  
  • It helps handle large PDF documents by loading and rendering pages as the user scrolls,  
  • It provides smooth navigation and optimized performance for viewing long PDF files.  

FAQ 

1. What is a PDF Viewer component, and how does it work in a Create React App?  

A PDF Viewer component is a component. It allows you to display and interact with PDF files in a React application. You can install and use a PDF Viewer component library in a Create React App. We can add it as a dependency in your project's package.json file. It will also import the necessary components into your code. The PDF Viewer component provides APIs and props to load and render PDF files. It helps navigate through pages and perform different actions. The actions can be zooming and searching within the PDF.  

  

2. How do you create a new PDF document using a popular JavaScript library?  

You can use the library's APIs and functions designed for PDF generation to create a PDF document. These APIs define the document structure and add text, images, and elements. The properties like page size and orientation and customize the PDF's appearance. You can use this functionality to save the generated PDF or perform operations.  

  

3. What is the Document component, and what purpose does it serve?  

We can provide the document component using the PDF Viewer library. It represents the PDF document itself. It is the main container for rendering and interacting with the PDF content. The Document component accepts props such as the source path or a PDF file. It provides APIs and callbacks for controlling the document's behavior. The behavior like loading different pages, retrieving document metadata, or handling user interactions.  

  

4. How do you open and edit Document files using this library?  

To open and edit files, you can use components dedicated to editing functionality. These features may include annotation tools, form-filling capabilities, text highlighting, and more. You can extract, change, or add content using the provided APIs. It helps specific pages or sections of the Document file. The library may also offer event listeners or callbacks. It handles user interactions and performs actions.  

  

5. What are the commands when using this library to display PDF files in React applications?  

The specific commands used to display PDF files in applications may vary. The commands include loading the PDF file. It will do so by providing the file path or object to the Document component. It will do so by setting up event handlers for user interactions. The interactions can be page navigation, zooming, and utilizing extra components or APIs. It helps enhance the PDF viewing experience. It can be displaying a sidebar with thumbnails or implementing text search functionality.  

 

6. Can I use this library to build products like Wojciech Maj's React-PDF-Viewer?  

You can use this library to build products like Wojciech Maj's React-PDF-Viewer. You can create your PDF Viewer with tailored features and design. You can leverage the library's components, APIs, and customization options. You can add functionalities, change styling, and extend capabilities per your needs. Building upon an existing PDF Viewer library can save development time. It provides a solid foundation for creating your custom PDF viewing experience.  

Trending Discussions on Document Editor

WinUI list control that allows for dynamic item size, reordering, and virtualization

Getting the default document editor toolbar in Mac Catalyst

extract the edited text and hide the right side toolbar by default in syncfusion document editor component

Google Drive API get AppProperties with API Key

AvalonEdit: Getting Visual Position for IBackgroundRenderer

How to center object with CSS transform scale

QUESTION

WinUI list control that allows for dynamic item size, reordering, and virtualization

Asked 2021-Jul-05 at 00:06

I am trying to implement a document editor similar to Notion or Craft but in a WinUI/UWP application. Instead of using a "single-field" editor (like MS Word has), these apps show a vertical stack of content rows (so-called "blocks") that can contain text, media, link previews, LaTeX, etc. These rows can be rearranged with a :: handle on the side:

Notion UI recording

So I've been looking for some list/stack control that:

  • Recycles the row views that are not visible (i.e. "virtualization" in the XAML terminology).
  • Allows to reorder rows by dragging and dropping them (single or multiple).
  • Automatically adjusts row heights based on their content growing or shrinking in height (due to the user's input or because the app's window resized horizontally and wrapped some content).

Features I do not need: headers, columns, sorting, filtering. I have reviewed the following controls in WinUI 2.x and Windows Community Toolkit, but it looks like each of them lacks one or more of the required capabilities.

ListView

It seems to be the go-to control for the lists with drag'n'drop, but it can't resize the items dynamically. Also, its dragging uses the whole item area while I need to make it available only with a :: handle on the side.

ItemsStackPanel

A virtualization-supporting version of StackPanel, but, as far as I understand, panels are supposed to be used for simple layouting of child items and not for presenting long lists based on a data source.

VariableSizedWrapGrid

This is the only list/grid control that officially declares the support of variable-sized items, but at the same time, it does not support virtualization. However, I found a solution from 2013 that is based on pre-calculating the content size for invisible elements.

ItemsRepeater

A very basic control that does not provide virtualization on its own: "ItemsRepeater supports virtualization when attached to a host that supports virtualization."

DataGrid

A rather heavy control from WCT that seems to be the only one to dynamically resize cells depending on their content. Unfortunately, it does not allow row reordering (only sorting), so I can't use it either.


Did I miss something? If not, I wonder which one would be the best to build upon. Thanks!

ANSWER

Answered 2021-Jun-30 at 06:55

I have to say there is no control could fulfill all demands. In fact, the :: is used to control darg the specified item, you could achieve similar behavior in ListView control.

The ListView allows you to easily reorder items inside a ListView by setting the CanReorderItems and AllowDrop properties to True.If you don’t want to allow the user to drag specific items, you could set the CanDragItems property to True, and add an event handler for the DragItemsStarting event. For the event handler, you can check any condition and then simply set the Cancel property of the event arguments to true if you want to cancel the dragging action. As follows:

Xaml code:

1<ListView x:Name="TargetListView"              
2                CanReorderItems="True" CanDragItems="True" AllowDrop="True"         DragItemsStarting="TargetListView_DragItemsStarting">
3
4            <ListViewItem>
5                <TextBlock x:Name="item1" Text="item1"/>
6            </ListViewItem>
7            <ListViewItem >
8                <TextBlock x:Name="item2" Text="item2"/>
9            </ListViewItem>
10            <ListViewItem>
11                <TextBlock x:Name="item3" Text="item3"/>
12            </ListViewItem>
13          
14  </ListView>
15

Code behind:

1<ListView x:Name="TargetListView"              
2                CanReorderItems="True" CanDragItems="True" AllowDrop="True"         DragItemsStarting="TargetListView_DragItemsStarting">
3
4            <ListViewItem>
5                <TextBlock x:Name="item1" Text="item1"/>
6            </ListViewItem>
7            <ListViewItem >
8                <TextBlock x:Name="item2" Text="item2"/>
9            </ListViewItem>
10            <ListViewItem>
11                <TextBlock x:Name="item3" Text="item3"/>
12            </ListViewItem>
13          
14  </ListView>
15private void TargetListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
16        {
17            e.Cancel = e.Items.Any(o =>
18            {
19                if (o is TextBlock t && t.Name.ToString() == "item2")
20                    return true;
21
22                return false;
23            });
24        }
25

As you can see, there are three textBlocks in ListView, the drag action of the textblock named item2 will be limited.

Source https://stackoverflow.com/questions/68183861

QUESTION

Getting the default document editor toolbar in Mac Catalyst

Asked 2021-Feb-16 at 10:53

I’ve just started porting my iPad app to the Mac using Catalyst. It’s a document editor and uses UIDocument. I’m trying to get the default toolbar behaviour for a document editor on macOS where there’s a dropdown to quickly name, tag, and move the document, and a subtitle that shows if the document has been edited. I can’t see any way to do this with Catalyst — is it possible?

Thanks,

Luke

Screenshot of Preview

ANSWER

Answered 2021-Feb-16 at 10:53

A representative from Apple confirmed to me that this is not possible using Catalyst. In my opinion this makes Catalyst unsuitable for document based apps at the moment (Big Sur is currently the latest version of macOS).

Source https://stackoverflow.com/questions/65614362

QUESTION

extract the edited text and hide the right side toolbar by default in syncfusion document editor component

Asked 2020-Oct-29 at 11:34

I am using ej2 sync fusion in my angular 7 application. How to extract the edited text in document editor component. and how to hide the right side toolbar on creation of the document editor component.

ANSWER

Answered 2020-Oct-29 at 11:34

Reg. how to extract the edited text.

To extract the whole document text in editor, you can either select the whole document by selectAll API from selection module and with text property from selection, you can get the selected text.

Please refer the below sample code snippets

//Selects the whole document.

containerInstance.documentEditor.selection.selectAll()

//To retrieve selected text

containerInstance.documentEditor.selection.text

You can also save the document as txt file in server-side and read the text file content to get the document text.

Please refer the below documentation for saving the document content in server side

https://ej2.syncfusion.com/angular/documentation/document-editor/export/#export-as-blob

In the above documentation example, sample will be saved as RTF document. You can change the format to TXT and read the text content from text file.

Reg. “how to hide the right-side toolbar on creation of the document editor component.”

Yes, document editor provides option to hide the properties pane. Please set showPropertiesPane property to false in component wrapper

Sample code snippet

<ejs-documenteditorcontainer #documenteditor_default [enableToolbar]=true [showPropertiesPane]=false height="600px" style="display:block;">

Source https://stackoverflow.com/questions/64552877

QUESTION

Google Drive API get AppProperties with API Key

Asked 2020-Oct-01 at 12:28
Question:

Is it possible to access the appProperties field in a Google Drive document via an unauthenticated user (i.e., via API Key or other method rather than Oauth)?

Background:

I have an app that works as a live document editor. It authenticates users via OAuth and allows them to save those documents to their google drive, and later re-open them in my app (google file ids are saved in my database and will load the document text into my app). Create()-ing and Get()-ing these files works fine as long as the user is signed in, and I have the "appProperties" field storing a couple of additional key metadata items.

As a next step, I would like to allow users to mark a document as "public view", and provide read-only access to their file, even for non-logged-in users. In my head, the flow would work as follows:

  1. User_A authenticates with OAuth and creates a document, saved to their google drive.
  2. User_A presses a button in my app, which sets the google document to a public sharing mode?
  3. App generates a "viewer" link that User_A can share with his friends.
  4. User_B does not have a Google account, but visits the "viewer link", and my app looks up the appropriate google document (using API key? since User_B is not logged in)
  5. Document is loaded into my app for viewing.

This seems to mostly work; I can read the file metadata just fine using the API key, and even get the file contents. Side Note: Why do we need the API Key at all, given the quote on the google drive api page: "Note: Authorization optional."

However, the "appProperties" field always returns empty when using the API key!

Edit: After further searching I am just more confused. The closest answer I could find was from this related question here on stackoverflow:

It's very simple. appPropperties is a private field and is available only to the application that added it.

Based on this, it seems Google Drive is treating requests from my app API Key and requests from OAuth users on my app as two separate apps?

Further, I would eventually like to allow users to collaborate on a single document, owned by one user. So instead of just providing a read-only "view" link, they could generate an "editor invitation" link that would allow an authenticated user (User_B gets a google account now) to be added as an authorized collaborator (but not simultaneous editing) on the original (User_A's) document. Is that even possible?

Note I am using the Node.js google api.

ANSWER

Answered 2020-Oct-01 at 12:28
This might be a bug:

appProperties are app-specific properties attached to a file. Any call from this app should be able to access them. Therefore, I think calls from this app using an API key should be able to retrieve these properties.

I could reproduce this behaviour: appProperties are populated when using OAuth, but not when using an API key, even though both are created from the same GCP project.

I filed a bug:

After researching this issue, I think this might be a bug. Therefore, I decided to file a bug on Issue Tracker:

To anyone affected by this, I'd suggest to click the top-left star in order to keep track of this and to help prioritizing it.

Reference:

Source https://stackoverflow.com/questions/63889368

QUESTION

AvalonEdit: Getting Visual Position for IBackgroundRenderer

Asked 2020-Jul-22 at 17:35

In my AvalonEdit-based document editor, I am trying to add marker lines to the text view to indicate folds in the document, in a similar way to how Visual Studio joins the start and end of code block braces with dotted lines.

I have something that produces the correct result if the document is scrolled to the very top, but it doesn't update correctly if the document is scrolled down. Specifically, the lines are drawn as if the text view wasn't scrolled at all, and was still at the top of the document. I suspect the problem has something to do with the TextViewPosition and GetVisualPosition lines, but I don't understand how to correctly get the adjusted visual position with scrolling.

(To be clear, I have checked, and the Draw method is being called at the appropriate times to update the background, it's just that scrolling isn't accounted for when it does)

What I have so far, is the following, on a class which implements IBackgroundRenderer:

1public void Draw(TextView textView, DrawingContext drawingContext) {
2    if (textView == null) { throw new ArgumentNullException(&quot;textView&quot;); }
3    if (drawingContext == null) { throw new ArgumentNullException(&quot;drawingContext&quot;); }
4    if (!textView.VisualLinesValid) { return; }
5    ReadOnlyCollection&lt;VisualLine&gt; visualLines = textView.VisualLines;
6    if (visualLines.Count == 0) { return; }
7
8    foreach (FoldingSection fold in foldingManager.AllFoldings.Where(f =&gt; !f.IsFolded)) {
9
10        DocumentLine startLine = textView.Document.GetLineByOffset(fold.StartOffset);
11        ISegment whitespace = TextUtilities.GetLeadingWhitespace(textView.Document, startLine);
12        if(whitespace.Length == 0) { continue; }
13        DocumentLine endLine = textView.Document.GetLineByOffset(fold.EndOffset);
14
15        TextLocation foldStart = textView.Document.GetLocation(whitespace.EndOffset);
16        TextLocation foldEnd = textView.Document.GetLocation(textView.Document.GetOffset(endLine.LineNumber, foldStart.Column));
17
18        // I am unsure exactly what TextViewPosition is meant to represent, in contrast to TextLocation
19        TextViewPosition startViewPos = new TextViewPosition(foldStart);
20        TextViewPosition endViewPos = new TextViewPosition(foldEnd);
21
22        // These lines are definitely not returning what I expect
23        Point foldStartPos = textView.GetVisualPosition(startViewPos, VisualYPosition.LineBottom);
24        Point foldEndPos = textView.GetVisualPosition(endViewPos, VisualYPosition.LineBottom);
25
26        Brush brush = new SolidColorBrush(LineColor);
27        brush.Freeze();
28        Pen dashPen = new Pen(brush, 0.5) { DashStyle = new DashStyle(new double[] { 2, 2 }, 0) };
29        dashPen.Freeze();
30        // New point created to avoid issues with nested folds causing slanted lines
31        drawingContext.DrawLine(dashPen, foldStartPos, new Point(foldStartPos.X, foldEndPos.Y));
32    }
33}
34

The folding for the document is based on whitespace (very similar to Python-style indentation), hence the use of the leading whitespace for finding the column.

In short, how does one get the properly adjusted visual position from the document line number and column?

ANSWER

Answered 2020-Jul-22 at 17:35

GetVisualPosition is documented as:

Returns: The position in WPF device-independent pixels relative to the top left corner of the document.

To use it for painting, you'll want to subtract the scroll position from it:

1public void Draw(TextView textView, DrawingContext drawingContext) {
2    if (textView == null) { throw new ArgumentNullException(&quot;textView&quot;); }
3    if (drawingContext == null) { throw new ArgumentNullException(&quot;drawingContext&quot;); }
4    if (!textView.VisualLinesValid) { return; }
5    ReadOnlyCollection&lt;VisualLine&gt; visualLines = textView.VisualLines;
6    if (visualLines.Count == 0) { return; }
7
8    foreach (FoldingSection fold in foldingManager.AllFoldings.Where(f =&gt; !f.IsFolded)) {
9
10        DocumentLine startLine = textView.Document.GetLineByOffset(fold.StartOffset);
11        ISegment whitespace = TextUtilities.GetLeadingWhitespace(textView.Document, startLine);
12        if(whitespace.Length == 0) { continue; }
13        DocumentLine endLine = textView.Document.GetLineByOffset(fold.EndOffset);
14
15        TextLocation foldStart = textView.Document.GetLocation(whitespace.EndOffset);
16        TextLocation foldEnd = textView.Document.GetLocation(textView.Document.GetOffset(endLine.LineNumber, foldStart.Column));
17
18        // I am unsure exactly what TextViewPosition is meant to represent, in contrast to TextLocation
19        TextViewPosition startViewPos = new TextViewPosition(foldStart);
20        TextViewPosition endViewPos = new TextViewPosition(foldEnd);
21
22        // These lines are definitely not returning what I expect
23        Point foldStartPos = textView.GetVisualPosition(startViewPos, VisualYPosition.LineBottom);
24        Point foldEndPos = textView.GetVisualPosition(endViewPos, VisualYPosition.LineBottom);
25
26        Brush brush = new SolidColorBrush(LineColor);
27        brush.Freeze();
28        Pen dashPen = new Pen(brush, 0.5) { DashStyle = new DashStyle(new double[] { 2, 2 }, 0) };
29        dashPen.Freeze();
30        // New point created to avoid issues with nested folds causing slanted lines
31        drawingContext.DrawLine(dashPen, foldStartPos, new Point(foldStartPos.X, foldEndPos.Y));
32    }
33}
34Point foldStartPos = textView.GetVisualPosition(startViewPos, VisualYPosition.LineBottom);
35Point foldEndPos = textView.GetVisualPosition(endViewPos, VisualYPosition.LineBottom);
36foldStartPos -= textView.ScrollOffset;
37foldEndPos -= textView.ScrollOffset;
38

As for TextLocation vs. TextViewPosition: there are some cases where there are multiple possible locations that map to the same TextLocation. There might be custom VisualLineElements with a documentLength of 0. Or maybe word-wrap is enabled and a line is wrapped at a position where there is no space character: then both the end of the first TextLine and the beginning of the second TextLine refer to the same position in the document.

A TextViewPosition carries some extra information that allows distinguishing these cases. This is mostly important for the caret, so that clicking somewhere places the caret in the clicked position; not another equivalent position.

Source https://stackoverflow.com/questions/63022892

QUESTION

How to center object with CSS transform scale

Asked 2020-Jun-17 at 07:26

I'm trying to implement a zoom in/out functionality, just like you would have on a document editor like google docs or any word processor application. The problem I'm having is that I cannot keep the "document" centered and also be able to scroll all of its parts into view. Here is a small demonstration of the problem: https://codepen.io/liviu_vasut/pen/dyGbwwO

1document.getElementById('objectToScale').style.transform = "scale(3)";
1document.getElementById('objectToScale').style.transform = "scale(3)";.container {
2  display: flex;
3  align-items: center;
4  justify-content: center;
5  padding: 5px;
6  width: 300px;
7  height: 200px;
8  border: 1px solid #000000;
9  left: 0px;
10  top: 0px;
11  margin: 10px;
12  overflow: auto;
13}
14
15.object {
16  position: relative;
17  width: 120px;
18  height: 120px;
19  display: inline-block;
20  background-color: grey;
21  border-radius: 25px;
22  padding: 5px;
23  transform-origin: center;
24  transform: scale(1);
25}
1document.getElementById('objectToScale').style.transform = "scale(3)";.container {
2  display: flex;
3  align-items: center;
4  justify-content: center;
5  padding: 5px;
6  width: 300px;
7  height: 200px;
8  border: 1px solid #000000;
9  left: 0px;
10  top: 0px;
11  margin: 10px;
12  overflow: auto;
13}
14
15.object {
16  position: relative;
17  width: 120px;
18  height: 120px;
19  display: inline-block;
20  background-color: grey;
21  border-radius: 25px;
22  padding: 5px;
23  transform-origin: center;
24  transform: scale(1);
25}&lt;div class="container"&gt;
26  &lt;div id="objectToScale" class="object"&gt;x&lt;/div&gt;
27&lt;/div&gt;

Thanks for your time.

ANSWER

Answered 2020-Jun-02 at 09:47

Actually, use the transform-origin: 0 0; and manually set the scrollbar to the center:

1document.getElementById('objectToScale').style.transform = "scale(3)";.container {
2  display: flex;
3  align-items: center;
4  justify-content: center;
5  padding: 5px;
6  width: 300px;
7  height: 200px;
8  border: 1px solid #000000;
9  left: 0px;
10  top: 0px;
11  margin: 10px;
12  overflow: auto;
13}
14
15.object {
16  position: relative;
17  width: 120px;
18  height: 120px;
19  display: inline-block;
20  background-color: grey;
21  border-radius: 25px;
22  padding: 5px;
23  transform-origin: center;
24  transform: scale(1);
25}&lt;div class="container"&gt;
26  &lt;div id="objectToScale" class="object"&gt;x&lt;/div&gt;
27&lt;/div&gt;var scaled = false;
28
29function toggleScale() {
30  [...document.getElementsByClassName('object')].forEach(e =&gt; {
31    e.classList.toggle('scaled');
32    e.parentElement.scrollTop = (e.parentElement.scrollHeight - e.parentElement.clientHeight) / 2;
33    e.parentElement.scrollLeft = (e.parentElement.scrollWidth - e.parentElement.clientWidth) / 2;
34  });
35}
1document.getElementById('objectToScale').style.transform = "scale(3)";.container {
2  display: flex;
3  align-items: center;
4  justify-content: center;
5  padding: 5px;
6  width: 300px;
7  height: 200px;
8  border: 1px solid #000000;
9  left: 0px;
10  top: 0px;
11  margin: 10px;
12  overflow: auto;
13}
14
15.object {
16  position: relative;
17  width: 120px;
18  height: 120px;
19  display: inline-block;
20  background-color: grey;
21  border-radius: 25px;
22  padding: 5px;
23  transform-origin: center;
24  transform: scale(1);
25}&lt;div class="container"&gt;
26  &lt;div id="objectToScale" class="object"&gt;x&lt;/div&gt;
27&lt;/div&gt;var scaled = false;
28
29function toggleScale() {
30  [...document.getElementsByClassName('object')].forEach(e =&gt; {
31    e.classList.toggle('scaled');
32    e.parentElement.scrollTop = (e.parentElement.scrollHeight - e.parentElement.clientHeight) / 2;
33    e.parentElement.scrollLeft = (e.parentElement.scrollWidth - e.parentElement.clientWidth) / 2;
34  });
35}* {
36  box-sizing: border-box;
37}
38
39.container {
40  display: flex;
41  align-items: center;
42  justify-content: center;
43  padding: 5px;
44  width: 300px;
45  height: 200px;
46  border: 1px solid #000000;
47  left: 0px;
48  top: 0px;
49  margin: 10px;
50  overflow: auto;
51}
52
53.object {
54  position: relative;
55  width: 120px;
56  height: 120px;
57  display: inline-block;
58  background-color: grey;
59  border-radius: 25px;
60  padding: 5px;
61  transform-origin: 0 0;
62}
63
64.scaled {
65  transform: scale(3);
66}
1document.getElementById('objectToScale').style.transform = "scale(3)";.container {
2  display: flex;
3  align-items: center;
4  justify-content: center;
5  padding: 5px;
6  width: 300px;
7  height: 200px;
8  border: 1px solid #000000;
9  left: 0px;
10  top: 0px;
11  margin: 10px;
12  overflow: auto;
13}
14
15.object {
16  position: relative;
17  width: 120px;
18  height: 120px;
19  display: inline-block;
20  background-color: grey;
21  border-radius: 25px;
22  padding: 5px;
23  transform-origin: center;
24  transform: scale(1);
25}&lt;div class="container"&gt;
26  &lt;div id="objectToScale" class="object"&gt;x&lt;/div&gt;
27&lt;/div&gt;var scaled = false;
28
29function toggleScale() {
30  [...document.getElementsByClassName('object')].forEach(e =&gt; {
31    e.classList.toggle('scaled');
32    e.parentElement.scrollTop = (e.parentElement.scrollHeight - e.parentElement.clientHeight) / 2;
33    e.parentElement.scrollLeft = (e.parentElement.scrollWidth - e.parentElement.clientWidth) / 2;
34  });
35}* {
36  box-sizing: border-box;
37}
38
39.container {
40  display: flex;
41  align-items: center;
42  justify-content: center;
43  padding: 5px;
44  width: 300px;
45  height: 200px;
46  border: 1px solid #000000;
47  left: 0px;
48  top: 0px;
49  margin: 10px;
50  overflow: auto;
51}
52
53.object {
54  position: relative;
55  width: 120px;
56  height: 120px;
57  display: inline-block;
58  background-color: grey;
59  border-radius: 25px;
60  padding: 5px;
61  transform-origin: 0 0;
62}
63
64.scaled {
65  transform: scale(3);
66}&lt;input type="button" onClick="toggleScale()" value="Toggle Scale" /&gt;
67
68&lt;div class="container"&gt;
69   &lt;div class="object"&gt;cannot see the entire object when scaled&lt;/div&gt;
70&lt;/div&gt;

Source https://stackoverflow.com/questions/62148727

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Document Editor

Tutorials and Learning Resources are not available at this moment for Document Editor

Share this Page

share link

Get latest updates on Document Editor