Hi,

1) document.setPageSize(); and document.setMargins(); will only take effect
starting with the next page so I am not surprised that margins for the first
page is 36 which is the default in iText. You need to specify margins at the
document declaration phase new Document(pageSize, margins...);

2) I do not actually see you setting margins. setPageSize() will set the
size of the pdfPage like A4 or US Letter. In order to set margins within the
page you need to call setMargin(...);

3) I do not think that margins are taken into account when using
getDirectContent().addTemplate();. It should only be for elements added
using document.add();

I think what you need to do here is to scale the imported page to the size
of the content area(page dimensions - margins) you want and then add to
document. If you read section on How to import pages using iText in the book
it should explain how you can scale the pages.

Good luck
Nurettin

On Thu, Nov 11, 2010 at 6:29 AM, riffla <rif...@hotmail.com> wrote:

>
> Hi
>
> This issue is about the loaded PDF and it's bottom margin.
> The PDF used as "template" and that is loaded at initialization is created
> in InDesign and the bottom margin is set to 64 (pt) but still when the
> writer adds a Paragraph text is written below that 64pt margin, how come.
> Is
> there a way to see - during debugging - that the margin actually is 64? Is
> the margin set in the loaded PDF template not even used. the code that
> loads
> the template is this:
>
>    document = new Document();
>    try {
>      writer = PdfWriter.getInstance(document, stream);
>    } catch (DocumentException docEx) {
>      throw new PdfGenerationException(docEx);
>    }
>    writer.setPageEvent(pdfEvtHandler);
>
>    setDocumentMetaData(applicationType);
>    document.open();
>    PdfLoader tLoader = new PdfLoader(writer);
>    PdfImportedPage tTemplate = null;
>    if (myCondition) {
>      try {
>        tTemplate =
> tLoader.readPage(CommonReportConfig.BTP_APPLICATION_NORMAL_TEMPLATE);
>      } catch (Exception ex) {
>        aLogger.error("Exception was caught when trying to read PDF
> Template: '" + CommonReportConfig.BTP_APPLICATION_NORMAL_TEMPLATE + "'.",
> ex);
>        throw new PdfGenerationException(ex);
>      }
>      document.setPageSize(tTemplate.getBoundingBox());
>      writer.getDirectContent().addTemplate(tTemplate, 0, 0);
>
>
> And during debugging I inspect the writer object and finds that
> writer.getPdfDocument() has a bottom margin of 36, and not 64 as I hoped
> for.
>
> So another question would be, if I set the the margins before loading the
> template from external file, will those margins be unaffected by the loaded
> template?
>
> /R
> --
> View this message in context:
> http://itext-general.2136553.n4.nabble.com/Problem-with-margin-tp3037663p3037663.html
> Sent from the iText - General mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>



-- 
Nurettin DAG
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to