Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. page won't fit in A4 (itextsharp dll used)

page won't fit in A4 (itextsharp dll used)

Scheduled Pinned Locked Moved C#
csharpjsonhelpquestion
1 Posts 1 Posters 0 Views 1 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.
  • S Offline
    S Offline
    stephan_007
    wrote on last edited by
    #1

    Hy everyone! I used the itextsharp dll http://itextsharp.sourceforge.net/examples/Chap0607.cs ccomponent to add images to a pdf document. In default it uses the squar format for the page. I didn't change this, but no matter which size i choose the pic to be or which parameter I try to use to set the location where the pic is located at, there is a white strip on top of the page. is there a chance to use 100% of the page? my code is

    Document document = new Document(PageSize.A4.Rotate());
    try
    {
    PdfWriter.GetInstance(document, new FileStream(outputPath, FileMode.Create));
    document.Open();
    for (int i = 0; i < list.Count; i++)
    {
    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(list[i]);
    // Querformat
    if (img.Width >= img.Height)
    {
    img.Alignment = iTextSharp.text.Image.MIDDLE_ALIGN;
    //img.Alignment = iTextSharp.text.Image.ALIGN_TOP;
    img.RotationDegrees = 0f;
    }
    // Hochformat
    else
    {
    img.Alignment = iTextSharp.text.Image.MIDDLE_ALIGN;
    //img.Alignment = iTextSharp.text.Image.ALIGN_TOP;
    img.RotationDegrees = 270;
    }
    //img.ScaleToFit(624.5f, 462);
    //img.ScaleToFit(687, 508);
    //img.ScaleToFit(720, 534);
    img.ScaleToFit(855, 550);
    document.Add(img);
    //Add a new Page for net next image
    document.NewPage();
    }
    // document.Close();
    }
    catch (System.Exception EX)
    {
    logger.Error(EX.ToString());
    }
    finally
    {
    document.Close();
    }

    is there a chance to fit the pic into the page to use the whole size, so to get rid of the white strip on top (compareable to the orange bar on top to the rest of this page here)? thanks! stephan.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups