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 8169069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:44:08+00:00 2026-06-06T20:44:08+00:00

I recognize there is a similar question on here, from a fellow who wanted

  • 0

I recognize there is a similar question on here, from a fellow who wanted to break a single file into multiple files. Regrettably, though, since there is a certain amount of overhead associated with creating a new file, this solution won’t work for me.

Background (not necessary to read):

What I’m trying to do is generate PDF files of arbitrary size to seed a database (i.e. calling a method with the size of the file desired, in kilobytes or megabytes, should generate a file of the desired size).

Currently, I’m ensuring the input data is incompressible by making it random and putting it in 1KB blocks (in paragraph form) into the file. After plotting the number of output bytes as a function of the number of desired bytes, I’ve altered the algorithm to account for this (pleasantly and expectedly) linear relationship.

However, due to the stochastic nature of the input data, there is a certain amount of uncertainty associated with this method, the absolute value of which increases with desired size (so, despite the fact that it’s hundredths of a percent off, those hundredths of a percent become pretty significant in absolute terms in a 20 MB file).

Optimally, I would be able to generate files of arbitrary size to within the kilobyte, but in order to do this I would need to know the file size after any given operation, and in order to know that, I’d need to know when PDFWriter writes its buffer. or at least how large that buffer is (i.e. if the buffer is less than one kilobyte, when it writes doesn’t matter because I only care about being accurate to within that margin).

The Question:

Is there a way to check the number of bytes of data actually to be written to disk in a PDF using text without actually closing the document?

Or does ‘closing the document’ just mean it flushes the buffer and closes the stream (i.e. it doesn’t need to write any additional non-user-input quantity of data to the file when it closes)?

  • 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-06-06T20:44:11+00:00Added an answer on June 6, 2026 at 8:44 pm

    When you build your PdfWriter, you must specify an OutputStream, that is not necessarily a FileOutputStream. So if you build it in this way

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PdfWriter writer = PdfWriter.getInstance(document, baos);
           . . .          
    

    you can check the buffer size in any moment:

     System.out.println("Current size: " + baos.size());
    

    Hope this will help you.

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

Sidebar

Related Questions

I wonder if there is a way to recognize the visit from user's iphone
In emacs, is there a way to get hideshow-mode to recognize multiple regular expressions
My question is if there is an alternative plugin similar to LogicLib? One that
There are many applications to recognize similar faces. The most popular is Picasa .
Is there a way or special curl option to recognize a no-connection-situation when curlGetResponse_
Here's the code. I have no idea why it doesn't recognize that it needs
I know there are other questions that are very similar to this, but their
I am trying to do something similar to what the user who asked this
How do I get Aptana to recognize .jspf files? I'd like to have syntax
I know that very similar question was posted some time ago and it was

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.