diegomura / diegomura/react-pdf

Vertically center inline images

Open
#2,833 8 comments 1 reaction 0 assignees View on GitHub
new feature
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**Is your feature request related to a problem? Please describe.**
**Describe the bug**
I am creating some functionality that allows a user to download a blog-like item as a PDF. The PDFs are rendered server-side. In these blogs, there are many occurrences of formulas in LaTeX, and I need a way to render these. To this end, I have created some custom code that converts LaTeX to a base64 PNG and I am now rendering these images inside text components.

The issue I'm facing is that I can't place the image over the text baseline to vertically centre the image.

**To Reproduce**
Steps to reproduce the behavior including code snippet (if applies):
The images are rendered using the following code snippet:
```typescript

```

The following images show in black where the image is rendered, and a red background for the text element in which it is rendered.
![image](https://github.com/user-attachments/assets/758e5051-a725-431e-8f37-6f157483c538)
![image](https://github.com/user-attachments/assets/ea361519-4b7a-4bca-948b-895a1cf0981a)

The reference outputs are the following:
image
image

**Describe the solution you'd like**
I would like to be able to add a `verticalAlign: 'middle'` style property to a `` component (or something similar).

**Describe alternatives you've considered**
At first, I tried to convert the LaTeX inputs to SVG, which I then converted to react-pdf's `` components. However, these can't be rendered inside of `` components.

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.