Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert a background image from my disk into restructuredtext pdf #1183

Closed
mpenning opened this issue Dec 18, 2023 · 2 comments
Closed

Insert a background image from my disk into restructuredtext pdf #1183

mpenning opened this issue Dec 18, 2023 · 2 comments

Comments

@mpenning
Copy link

I am using Python3.11.2 with rst2pdf version 0.101.

I need to insert an image as a background image and then overlay some text on that image.

I tried this but it did not insert the image on the page... only the text before it.

- bullet 1
- bullet 2

.. raw:: html

   <div>
      <style>
         body {
           background-color: white;
           background-image: url('/home/mpenning/ciscoconfparse_logo_bw_01.png');
           z-index: -1;
         }
      </style>
   </div>

What should I do to insert an image behind my text on a pdf page?

@akrabat
Copy link
Member

akrabat commented Dec 18, 2023

Create a new page using the PageBreak directive as that takes a background parameter like this:

PageBreak emptyPage background=/home/mpenning/ciscoconfparse_logo_bw_01.png

I use relative paths, but I guess that a fully qualified one will work.

@mpenning
Copy link
Author

mpenning commented Dec 18, 2023

The explicit solution that worked for me... a title page and then the next page with text overlayed on the background image... FYI, center is the default

Insert Presentation Title Here

.. image:: /home/mpenning/ciscoconfparse_logo_bw_01.png
   :align: center

.. raw:: pdf

    PageBreak background=/home/mpenning/ciscoconfparse_logo_bw_01.png fit-background-mode=center

- Bullet 1
- Bullet 2
- Bullet 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants