Skip to content

Transparent background in PDF previews #244

Open

Description

@audungk

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)
}

Activity

  1. philprime commented on Dec 2, 2020

    @philprime
    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.

  2. philprime commented on May 13, 2021

    @philprime
    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 // <----
  3. audungk commented on May 18, 2021

    @audungk
    Author

    Sensible! Looks good to me!

  4. philprime commented on May 22, 2021

    @philprime
    Member

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

  5. stefanovnt commented on Aug 24, 2021

    @stefanovnt

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

  6. philprime commented on Aug 25, 2021

    @philprime
    Member

    @stefanovnt thank you for your feedback!

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

  7. added
    merged-for-releaseIssue is merged into develop branch to be included in next release
    on Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmerged-for-releaseIssue is merged into develop branch to be included in next release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions