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

Transparent background in PDF previews #244

Open
audungk opened this issue Oct 14, 2020 · 6 comments
Open

Transparent background in PDF previews #244

audungk opened this issue Oct 14, 2020 · 6 comments
Labels
enhancement merged-for-release Issue is merged into develop branch to be included in next release

Comments

@audungk
Copy link

audungk commented Oct 14, 2020

What did you do?

I created a PDFDocument, and rendered it. When the preview was displayed in Mail for macOS, the background was transparent.

What did you expect to happen?

I expected the background to be white, or a a possibility to set a fill coloraturas

What happened instead?

The background was transparent

TPPDF Environment

TPPDF version: 2.3.1 ℹ
Xcode version: 12 ℹ
Swift version: 5 ℹ

Demo Code / Project

let document = PDFDocument(format: .a4)
document.set(font: Font.systemFont(ofSize: 12))
document.add(text: "Hello World")
let generator = PDFGenerator(document: document)
do {
    return try generator.generateURL(filename: "Utlånserklæring.pdf")
} catch {
    print(error)
}
@philprime
Copy link
Member

Hi there! Thanks for opening up this issue.

This should definitely be a feature so it is possible to set a paper/background color.

@philprime
Copy link
Member

I am thinking about looking further into this and therefore RFC:

API

First off I would add a property background to the PDFDocument class with the following structure:

struct PDFDocumentBackground {
    var color: Color?
}

This allows to add more background alternatives further down the road as they can easily be added next to color.

Example:

let document = PDFDocument(format: .a4)
document.set(font: Font.systemFont(ofSize: 12))
document.add(text: "Hello World")
document.background.color = .green // <----

@audungk
Copy link
Author

audungk commented May 18, 2021

Sensible! Looks good to me!

@philprime
Copy link
Member

I created a pull request PR #277.
Can you please test it?

@stefanovnt
Copy link

I am really interested in this feature, I have tested it and it's working correctly for me 👌

@philprime
Copy link
Member

@stefanovnt thank you for your feedback!

I will go ahead and review the PR once more and merge it soon

@philprime philprime added the merged-for-release Issue is merged into develop branch to be included in next release label Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement merged-for-release Issue is merged into develop branch to be included in next release
Projects
None yet
Development

No branches or pull requests

3 participants