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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:59:54+00:00 2026-05-17T02:59:54+00:00

I am trying to generate a PDF using iTextSharp. It will consists of a

  • 0

I am trying to generate a PDF using iTextSharp.
It will consists of a number of images, each with a heading preceding it. But when I generate the PDF, the order of the elements is not preserved – multiple headings are grouped together etc.

I am wrapping the header and image in a single paragraph as follows:

' Create paragraph and heading
Dim paragraph As New iTextSharp.text.Paragraph()
Dim heading As New iTextSharp.text.Chunk("Image title" & vbNewLine, pdfHeadingFont)

' Create image from Chart
Dim image = GetPdfImage(Me.chtMain)
Dim width = iTextSharp.text.PageSize.A4.Width - pdfDocument.LeftMargin - pdfDocument.RightMargin
Dim height = iTextSharp.text.PageSize.A4.Height - pdfDocument.TopMargin - pdfDocument.BottomMargin
image.Alignment = image.ALIGN_CENTER Or image.TEXTWRAP
image.ScaleToFit(width, height)

' Add heading and image to paragraph
paragraph.Add(heading)
paragraph.Add(image)

' Add paragraph to document
pdfDocument.Add(paragraph)

Why are the image and heading not placed together in the PDF? Could I be doing this in some other way?

Thank you,

Martin

  • 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-17T02:59:55+00:00Added an answer on May 17, 2026 at 2:59 am

    Figured it out, thanks to this question.

    Apparently, setting PdfWriter.StrictImageSequence = true resolves this issue.
    iTextSharp "optimizes" your document by trying to fit as many paragraphs as possible on every single page – regardless of order.

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

Sidebar

Related Questions

I'm trying to save to databse a pdf file generated by itextsharp. But, I
I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML
I'm trying to generate a PDF document using FOP and Java. I receive the
I'm trying to generate a PDF document using FOP. The pdf generation code is
I'm trying to generate a pdf from template using this snippet: def write_pdf(template_src, context_dict):
I'm trying to have table borders in my PDF using pisa to generate the
I am using Websupergoo's ABCpdf for ASP.NET and I am trying to generate PDF's
G'day guys, trying to build a small invoicing system (that can generate PDF's using
I'm trying to generate a unique ID in php in order to store user-uploaded
I'm trying to generate code coverage reports with EMMA using tests of which some

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.