Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
UIPrintInteractionController printingItems not showing up / working

Pretty straightforward...

I consider myself a fairly well-seasoned iOS developer these days, but this one seems like a glaring bug in iOS, unless I missed something.

Please see the code below.

The file paths point to two one-page PDFs.

What shows up is a Print interaction controller with no content to print.

If I instead only do 1 file at a time like this:

pc.printingItem = [NSURL fileURLWithPath:filePath1];

it works like a champ.

What am I missing here?!

UIPrintInteractionController *pc = [UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputPhoto;
printInfo.orientation = UIPrintInfoOrientationLandscape;
pc.printInfo = printInfo;

pc.printingItems = @[[NSURL fileURLWithPath:filePath1], 
                     [NSURL fileURLWithPath:filePath2]];

[pc presentAnimated:YES completionHandler:completionHandler];

enter image description here

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I had the same issue and solved it by setting the printingItem property with raw data of my PDF file.

// Here is a class I created that works with `UIActivityViewController`,
// feel free to tweak to your needs.

final class CustomActivityViewController: UIActivityViewController {

    init(with filePath: URL, and fileData: Data?) {
        super.init(activityItems: [filePath], applicationActivities: [])
    
        completionWithItemsHandler = { activity, complete, items, error in
        
            if activity == .print {
            
                let printInfo = UIPrintInfo(dictionary: nil)
                printInfo.jobName = filePath.lastPathComponent
                printInfo.outputType = .general
            
                let printer = UIPrintInteractionController.shared
                printer.printingItem = fileData // <-- This is the cure.
                printer.printInfo = printInfo
            
                printer.present(animated: true, completionHandler: nil)
            }
        }
    }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda