Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601124
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:34:56+00:00 2026-05-18T20:34:56+00:00

I am wanting to learn how to generate a PDF, I don’t want to

  • 0

I am wanting to learn how to generate a PDF, I don’t want to use any third party tools, I want to create it myself in code. The only things I have seen so far as examples is code I have looked at by opening up reflector on a 3rd party dll, to see what is happening. Unfortunately the dll’s I have seen so far seem to be hitting user32.dll and gdi32.dll, to help creating the pdf document, my issue is I have no idea what they are doing and more importantly why ?

Does anyone have any good tutorials or references, which may point me in the right direction.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:34:56+00:00Added an answer on May 18, 2026 at 8:34 pm

    The spec is the ultimate guide. Here is what you will ultimately have to do:

    • Write a header
    • Write objects that define the content
    • Write a cross-reference table
    • Write a trailer

    The header is easy – it defines that the file is PDF and the version.
    Objects data types in PDF. This includes bool, number, string, list/array, dictionary and stream.
    Objects are either written directly or indirectly.
    Direct objects are written as is.
    Indirect objects are written like this:

    <objid> <generation> obj <direct object> endobj
    

    For example, I could write:

    3 0 obj (This is a string within PDF.) endobj
    

    And whenever I want to use that string elsewhere, I just have to use an indirect reference, which is defined as:

    <objid> <generation> R
    

    in this case, I could refer to my string as:

    3 0 R
    

    To quickly find an object, there is a cross reference table that tells where an object of a particular id and generation lives in the file.

    So, in addition to simply writing objects to the file, you have to keep track of the file position where indirect objects have been defined.

    All of this is doable, but you’re going to quickly find that as you write these files that it’s going to become really challenging to make changes in your output stream and keep things neat and tidy. What’s worse, is that other people have done this too, so now there are a pile of garbage PDFs out in the wild that Acrobat manages to cope with somehow. For example, GhostScript (hopefully this is fixed), produced PDFs whose cross-reference tables were complete garbage – they pointed at nothing useful. Then there are producers that out and out violate the spec by using the wrong data type for dictionary entries or others that have spec-required information missing.

    It’s fairly nightmarish to consume PDF.

    Still, it’s an interesting exercise, but if you want to do anything significant, you need to start writing good tools that manage all the indirect references for you and the cross reference tables and dictionaries and type checking and so on and so forth. In the end, you’ll find that maybe an existing library would serve you better.

    And being the author of tools that consume and generate PDF, I will plead that you don’t let any of your non-compliant PDFs out into the wild.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to learn how to generate a PDF, I don't want to
I'm really wanting to learn assembly. I'm pretty good at c/c++, but want a
I don't have much experience with Renderscript , but I'm wanting to learn a
I want to learn VHDL but I really don't know from where to start.
I'm experienced with .NET MVC and wanting to learn a Python framework. I chose
Alrighty so, I've been wanting to learn C for awhile, and now I have
I have been wanting to learn to write a Flash app so that it
I'm wanting to learn more about IL and CLR / DLR under the hood.
I've been wanting to learn some Haskell for a while now, and I know
I come from a Java background. I am wanting to learn more about concurrency

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.