Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PDF with Table of Contents/Bookmarks?
Forum Updated to NodeBB v4.3 + New Features

PDF with Table of Contents/Bookmarks?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 1.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheRedQueen
    wrote on last edited by
    #1

    Hi everyone,

    We're using Qt 5.6.1 (soon to be 5.12.1) for a large C++ Windows/Mac application. In our app, we give users the ability to export their data to a PDF. We're currently using a 3rd party library to achieve this, but we'd like to use native Qt if possible moving forward. However, due to the size of the data we export, navigating around the document is crucial (for a large user file, we're looking at ~14K pages in the export).

    Is there currently a way to create a table of contents/bookmarks via a generated PDF in Qt 5.6.1/5.12.1? If so, what would be the best way to set this up? If not, are there any plans in the future to add this feature?

    A few limitations we are under:

    • We can't use Chromium since we support WinXP still (so WebEngine is a problem)
    • We're only interested in exporting to PDF - reading it isn't a requirement for us

    Thank you in advance!

    jsulmJ 1 Reply Last reply
    1
    • T TheRedQueen

      Hi everyone,

      We're using Qt 5.6.1 (soon to be 5.12.1) for a large C++ Windows/Mac application. In our app, we give users the ability to export their data to a PDF. We're currently using a 3rd party library to achieve this, but we'd like to use native Qt if possible moving forward. However, due to the size of the data we export, navigating around the document is crucial (for a large user file, we're looking at ~14K pages in the export).

      Is there currently a way to create a table of contents/bookmarks via a generated PDF in Qt 5.6.1/5.12.1? If so, what would be the best way to set this up? If not, are there any plans in the future to add this feature?

      A few limitations we are under:

      • We can't use Chromium since we support WinXP still (so WebEngine is a problem)
      • We're only interested in exporting to PDF - reading it isn't a requirement for us

      Thank you in advance!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TheRedQueen To my knowledge you can only export to PDF in Qt using QPrinter, see https://wiki.qt.io/Handling_PDF

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      JonBJ 1 Reply Last reply
      1
      • jsulmJ jsulm

        @TheRedQueen To my knowledge you can only export to PDF in Qt using QPrinter, see https://wiki.qt.io/Handling_PDF

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @jsulm , @TheRedQueen
        It depends on what you mean by "printer", but since that wiki was written there is now (Qt 5.something, maybe wiki could do with updating) https://doc.qt.io/qt-5/qpdfwriter.html. That would be in addition to existing methods (a) via QPrinter.PdfFormat and (b) via QWebEngine, but it's still intended for a "painting device".

        At any rate, none of these is going to generate anything like an index. You might intercept the PDF being generated for this, or you might post-process the PDF output file, but you're liable to still want a third-party library....

        1 Reply Last reply
        2
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Are you looking for QPdfWriter ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            As far as i know, QPdfWriter can't create bookmarks.
            however, the Jonas poster there seems to have added it.
            https://bugreports.qt.io/browse/QTBUG-3893
            in
            https://bitbucket.org/jonaslarsson/qextpdfwriter/src
            However, its somewhat old, so might not be good enough for newest Qt.

            JonBJ 1 Reply Last reply
            2
            • mrjjM mrjj

              Hi
              As far as i know, QPdfWriter can't create bookmarks.
              however, the Jonas poster there seems to have added it.
              https://bugreports.qt.io/browse/QTBUG-3893
              in
              https://bitbucket.org/jonaslarsson/qextpdfwriter/src
              However, its somewhat old, so might not be good enough for newest Qt.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @mrjj , @SGaist
              Good one, didn't know about that patch-addition. It says

              Hope to see PDF outlines feature added to official Qt.

              because I only know it's not in existing QPdfWriter documentation.

              Let me get one thing clear: for PDF my code used to use QPrinter, now it uses QWebEnginePage::printToPdf(). I do not use QPdfWriter (at least not explicitly). I have asked before what, if any, is the relationship in the PDF generation between these 3 classes? Does the code/patch for TOC etc. mean that if I wish to avail myself of it I will need to change over to QPdfWriter, it will not be available from the other two classes? Thanks.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved