E Plischke wrote:
> Hi, following instruction has no effect:
> 
> [CODE]
> 
>         pdfCopy.getDirectContent().addTemplate(
>           pdfCopy.getImportedPage(pdfReader, 1), tagetAffineTransform
>         );
> 
> [/CODE]
> 
> is this a bug or do I miss something?

That's not a bug. As documented in chapter 6 of the book: you can't 
manipulate the content of the pages if you choose PdfCopy. Unless you 
use the methods described in section 6.4.1 of the Second Edition of 
iText in Action.

> i want to merge some pages from source PDF into a new Document, while 
> some of them is a simple 1:1 copy (which are handled by 
> PdfCopy.addPage(..) method and some of them are going to be weaved 
> rotated and scaled, so I use the PdfContentByte.addTemplate() to achieve 
> it (like in code above).

If you only need to rotate the page, then you should try the RotatePages 
example from section 13.3.2. It's an example with PdfStamper, but it 
should also work for PdfCopy.

If you really need to scale the page, reconsider: why do you want to 
scale it? PDF is a digital format, the viewer can scale it for you.

> The issue is that with PdfWriter (instead of PdfCopy) the addTemplate() 
> works fine, but not when applied on PdfCopy object, and while working 
> with PdfWriter I cannot simply copy a page as-is from source PDF,

With PdfWriter you can copy the CONTENT of the page AS-IS from the 
source PDF, WITHOUT the annotations, because annotations are not part of 
the page content. Is that why you claim that you can't copy a page AS-IS 
with PdfWriter?

> therefore I wanted to handle both cases with PdfCopy instance.

Yes, but if you use addTemplate(), you only copy the page content, not 
the annotations. And if that's your problem with PdfWriter, your (wrong) 
approach wouldn't solve anything, would it?

I'd use the RotatePages approach and NOT scale the pages, only rotate 
them (if necessary).

Note that I have no idea what you mean by "weaved". Are you talking 
about superimposing pages? In that case, you need the "Adding content 
with PdfCopy" example from section 6.4.1.

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to