[iText-questions] BaseFont.isFontSpecific() == true; text uses 0xF0xx form

2010-12-17 Thread David Thielen
Hi all;

Found an interesting issue - posted so others can find via Google. If a font is 
set to BaseFont.isFontSpecific() then the string passed in must have the chars 
on the range 0x00 - 0xFF. If the text is in the form 0xF0__ then it will not 
display them (Word uses this approach).

So if it's isFontSpecific then 0xF012 must be changed to 0x0012.

Thanks - dave

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d___
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

Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread qplace
1T3XT BVBA  1t3xt.info> writes:
> 
> You were able to get the MediaBox and CropBox rectangle (p150); you
> were able to get the field positions (p264). What more do you need?
> I don't understand the question. According to you, what is missing
> in the book?

First, let me thank you for your help once again. Your replies helped me to 
understand the role of media/crop boxes that I did not take into account when 
retrieving field property.

Regarding the book - nothing is missing there. I enjoy reading it, it is a 
huge help and my money were very well spent on it. I was only trying to say 
that two pieces of information (p.144 - media) and 263-264 (getFieldPos) are 
not linked together in a clear way. I'd say that it will be a good thing to 
highlight the need to always use media boxes to correctly identify the field 
position coordinates. May be there is somewhere a paragraph regarding this 
topic, but I did not find it. I am still learning the product.






--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


[iText-questions] Apend pdf, tiff, jpg or other images to a master pdf

2010-12-17 Thread tim clark
All
I had a task recently to create a master customer electronic billing
document the first document was a multipage pdf invoice the subsequent
documents were scanned 1 page  images in a variety of images formats.
Each master customer billing pdf document was later combine into a single
batch pdf document.

I choose to use  the  iTextSharp.text.pdf.PdfSmartCopy interface
to append the  documents to the master oPdfCopy

The use pattern in vb.net looks like this (w/o the declares)
... oFiles is an xml node structure with the files to combine

oPdfDoc=New iTextSharp.text.Document(PageSize.LETTER)
 oFileStream = New
System.IO.FileStream(oFiles.GetAttribute("OutputFilePath"),
IO.FileMode.Create, IO.FileAccess.ReadWrite)
 oPdfCopy = New iTextSharp.text.pdf.PdfSmartCopy(oPdfDoc, oFileStream)
 For Each oFile In oFiles.ChildNodes

  Select Case Path.GetExtension(oFile.GetAttribute("FilePath")).ToLower
Case ".jpg", ".png", ".bmp", ".gif", "tif", "wmf"
  oPdfImgDoc = New iTextSharp.text.Document(PageSize.LETTER)
  oStream = New System.IO.MemoryStream
  oPdfImgWri =
iTextSharp.text.pdf.PdfWriter.GetInstance(oPdfImgDoc, oStream)
  oPdfImgWri.CloseStream = False
  oPdfImgDoc.Open() '//Open Document to write
  
'http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images
  Dim oImg As iTextSharp.text.Image =
iTextSharp.text.Image.GetInstance(oFile.GetAttribute("FilePath"))
  oImg.ScalePercent(24.0F) 'scale% a std image from 72dpi to
300dpi for pritning 72/300 * 100
  'oImg.ScaleToFit(oPdfImgDoc.PageSize.Width,
oPdfImgDoc.PageSize.Height)
  'oImg.SetAbsolutePosition(oPdfImgDoc.PageSize.Width,
oPdfImgDoc.PageSize.Height)
  oPdfImgDoc.Add(oImg)
  oPdfImgDoc.Close()
  oStream.Seek(0, IO.SeekOrigin.Begin)
  oPdfReader = New iTextSharp.text.pdf.PdfReader(oStream)

  For pageLoop = 1 To oPdfReader.NumberOfPages
oPdfCopy.AddPage(oPdfCopy.GetImportedPage(oPdfReader,
pageLoop))
  Next
  oPdfCopy.FreeReader(oPdfReader)
  oPdfCopy.Flush()
Case ".pdf"
  oPdfReaderFile = New
iTextSharp.text.pdf.RandomAccessFileOrArray(oFiles.GetAttribute("OutputFilePath")",
True)
 oPdfReader = New iTextSharp.text.pdf.PdfReader(oPdfReaderFile,
Nothing)
 For pageLoop = 1 To oPdfReader.NumberOfPages
  oPdfCopy.AddPage(oPdfCopy.GetImportedPage(oPdfReader,
pageLoop))
 Next
Next

The case statement above is a bit of a hack for images ...
it does work but its not very efficient
So I struggled a bit to find an interface that exposed a full pdfwriter via
  iTextSharp.text.pdf.PdfSmartCopy interface so I could just
append images to the   iTextSharp.text.pdf.PdfSmartCopy interface to
pdfwriter

This was  a couple of attempts that failed :(
 oPdfCopy.NewPage()
 oPdfCopy.Add(oImg)

then I tried this
 oPdfCopy.NewPage()
 oIndirectPageref = oPdfCopy.GetPageReference(iPageCnt)
 oPdfCopy.AddDirectImageSimple(sigImg, oIndirectPageref)

 but I could never get the image into the pdf pages
it was part of the document but not part of a display page

Can anyone drop a hint as to how you can use the
 iTextSharp.text.pdf.PdfSmartCopy  to append images
& create a new page in the pdfcopy document
It seems like AddDirectImageSimple would be the route to go
if I could properly create a new blank page using the pdfcopy & get
back an the correct page reference but oPdfCopy.NewPage()
does not seems to be the magic bullet :(
 


--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] Text search in a pdf with swf object embedded

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 14:55, Leonard Rosenthol schreef:
> No, Acrobat/Reader do not search SWFs.
>
> And for future reference, I am now the "PDF Architect" at Adobe.  So it's now 
> all my fault ;).
1T3XT takes paper copy of "iText in Action" book, strikes the words 
"technical standards evangelist" on page xxi and replaces them with 
"architect" ;-)

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] Text search in a pdf with swf object embedded

2010-12-17 Thread Leonard Rosenthol
No, Acrobat/Reader do not search SWFs.

And for future reference, I am now the "PDF Architect" at Adobe.  So it's now 
all my fault ;).

-Original Message-
From: Matteo [mailto:interesa...@gmail.com] 
Sent: Friday, December 17, 2010 8:30 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Text search in a pdf with swf object embedded


Hi all,
I have created a PDF from a swf file containing some text. The text is
selectable inside the pdf BUT I cannot search for a world using the find
function. There is a way to make the text inside the swf searchable by adobe
reader?

Thanks,
Matteo
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Text-search-in-a-pdf-with-swf-object-embedded-tp3092539p3092539.html
Sent from the iText - General mailing list archive at Nabble.com.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] Text search in a pdf with swf object embedded

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 14:29, Matteo schreef:
> Hi all,
> I have created a PDF from a swf file containing some text. The text is
> selectable inside the pdf BUT I cannot search for a world using the find
> function.
It would surprise me if Adobe Reader's search function was able to 
search inside the embedded swf file.
PDF technology is completely different from Flash. Adobe Reader needs 
the Flash plug-in to run the swf.
> There is a way to make the text inside the swf searchable by adobe
> reader?
I don't think so, but this sounds like a question for Leonard (Adobe's 
PDF Technical Standards Evangelist).
Watch the list for his answer.

By the way: PLEASE SUBSCRIBE to the mailing list.
Not subscribing means you're mail can get lost in the huge load of SPAM 
we're receiving.
It can also mean you don't receive useful answers.
It certainly means you're giving us administrative work we prefer to avoid.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] How can i change the margins of a pdf that there previously?

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 14:02, pepepg schreef:
> HI, I need to change the margins of a pdf that there previously,
You probably mean that you want to change the page boundaries such as 
the MediaBox and the CropBox.
That's explained on p441 of the Second Edition of "iText in Action".
I don't know where you found your code sample, but I'm not surprised 
that it doesn't work.

By the way: PLEASE SUBSCRIBE to the mailing list.
Not subscribing means you're mail can get lost in the huge load of SPAM 
we're receiving.
It can also mean you don't receive useful answers.
It certainly means you're giving us administrative work we prefer to avoid.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


[iText-questions] Text search in a pdf with swf object embedded

2010-12-17 Thread Matteo

Hi all,
I have created a PDF from a swf file containing some text. The text is
selectable inside the pdf BUT I cannot search for a world using the find
function. There is a way to make the text inside the swf searchable by adobe
reader?

Thanks,
Matteo
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Text-search-in-a-pdf-with-swf-object-embedded-tp3092539p3092539.html
Sent from the iText - General mailing list archive at Nabble.com.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


[iText-questions] How can i change the margins of a pdf that there previously?

2010-12-17 Thread pepepg

HI, I need to change the margins of a pdf that there previously, I've tried
PdfStamper  and also PdfCopy, but have not succeeded.

This is the code:


  private ByteArrayOutputStream formateaDocumento(ByteArrayInputStream
input)
  throws DocumentException, IOException 
  {
ByteArrayOutputStream byteArrayOutputStreamPdf = new
ByteArrayOutputStream();
PdfReader reader = new PdfReader(input);
int pages_number = reader.getNumberOfPages();
if (pages_number > 0) 
{
  Document document = new Document(reader.getPageSizeWithRotation(1));
  document.setMargins(10, 10, 10, 10);
  
  PdfCopy copy = new PdfCopy(document, byteArrayOutputStreamPdf);
  copy.setMargins(10, 10, 10, 10);

  document.open();
  
  for (int i = 1; i <= pages_number; i++) 
  {
PdfImportedPage page = copy.getImportedPage(reader, i);
copy.addPage(page);
  }
  
  document.close();
  
}
  
return byteArrayOutputStreamPdf;
  } 




Thanks
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/How-can-i-change-the-margins-of-a-pdf-that-there-previously-tp3092507p3092507.html
Sent from the iText - General mailing list archive at Nabble.com.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread 1T3XT BVBA

Op 17/12/2010 12:15, qplace schreef:


Thank you for the quick reply. I checked Rectangle.Left value as it is
returned from PdfReader.GetPageSize and PdfReader.GetCropBox. Indeed, the
document in question produced negative "left" property in both rectangles, and
the documents where I had no issues have zeroes.


You were assuming that the origin of the coordinate system is (0,0). 
That assumption was wrong. See p144 of the Second Edition of "iText in 
Action": "This assumption is correct as long as the media box is defined 
with (0,0) as the coordinate for its lower-left corner, but that's not 
mandatory. It's perfectly OK for an application to create a media box 
with a different origin."




Do you know of any references regarding this issue in the documentation/IText
book? I own the book, but can't find anything that talks about combining
getFieldPosition and relative position of the page rectangles?
You were able to get the MediaBox and CropBox rectangle (p150); you were 
able to get the field positions (p264). What more do you need? I don't 
understand the question. According to you, what is missing in the book?
--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d___
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

Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread qplace
1T3XT BVBA  1t3xt.info> writes:

> 
> Op 17/12/2010 11:43, qplace schreef:
> > Thank you for the reply. That is what I am using to determine field
> > coordinates, call to getFieldPositions. For most of the pdf documents that 
I
> > tested it works fine.
> OK.
> >   There is one document, however, where this method
> > returns 0 for the left coordinates. I am using following method to find the
> > left coordinate of the field (itextsharp):
> > AcroFields.FieldPosition.position.Left.
> >
> > When I open this particular document in Acrobat I noticed that the left 
border
> > of the field sits exactly on the left margin of the page.
> The coordinate of the lower-left corner of a document is usually[*] (0, 0).
> So if the left border of the field sits exactly on the left margin of 
> the page,
> then a result of 0 is correct, isn't it? If not, I don't understand the 
> question.
> 
> [*] There are PDFs with a different value for the origin, check the MediaBox
> and the CropBox to be sure.

Thank you for the quick reply. I checked Rectangle.Left value as it is 
returned from PdfReader.GetPageSize and PdfReader.GetCropBox. Indeed, the 
document in question produced negative "left" property in both rectangles, and 
the documents where I had no issues have zeroes. Judging by the value it is 
what I have to add to the value of "position.left" returned from the 
getFieldPosition.

Do you know of any references regarding this issue in the documentation/IText 
book? I own the book, but can't find anything that talks about combining 
getFieldPosition and relative position of the page rectangles?




--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 11:43, qplace schreef:
> Thank you for the reply. That is what I am using to determine field
> coordinates, call to getFieldPositions. For most of the pdf documents that I
> tested it works fine.
OK.
>   There is one document, however, where this method
> returns 0 for the left coordinates. I am using following method to find the
> left coordinate of the field (itextsharp):
> AcroFields.FieldPosition.position.Left.
>
> When I open this particular document in Acrobat I noticed that the left border
> of the field sits exactly on the left margin of the page.
The coordinate of the lower-left corner of a document is usually[*] (0, 0).
So if the left border of the field sits exactly on the left margin of 
the page,
then a result of 0 is correct, isn't it? If not, I don't understand the 
question.

[*] There are PDFs with a different value for the origin, check the MediaBox
and the CropBox to be sure.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread qplace
 17/12/2010 4:13, qplace:
> > How to retrieve the page margins from the existing document?
..
> > Using "TextMarginFinder" apparently retrievs the margins of the existing 
text
> > on a page. My situation is that the document I am reading have only fields 
and
> > no text...

1T3XT BVBA  1t3xt.info> writes:
> You should retrieved the coordinates of the fields (method 
> getFieldPositions) and use that information.
> 

Thank you for the reply. That is what I am using to determine field 
coordinates, call to getFieldPositions. For most of the pdf documents that I 
tested it works fine. There is one document, however, where this method 
returns 0 for the left coordinates. I am using following method to find the 
left coordinate of the field (itextsharp):
AcroFields.FieldPosition.position.Left.

When I open this particular document in Acrobat I noticed that the left border 
of the field sits exactly on the left margin of the page. That is why I 
thought that I should find the page margin.

Any help/advise on this matter is greatly appreciated




--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] DottedLineSeparator Questions

2010-12-17 Thread 1T3XT BVBA
Op 16/12/2010 19:27, Bob Barnes schreef:
> Hi all,
>
> Does anyone have any suggestions for using the DottedLineSeparator or 
> subclassing it to create better looking 'dots'? I've tried playing with line 
> width and a few other settings, but it still looks 'pixelated', especially 
> when the pdf is viewed in less than actual size. Has anyone created a 
> separator class that uses periods instead that they'd be willing share or 
> have ideas about how to create one?
Currently the DottedLineSeparator draws a dotted line using a specific 
dash pattern and line cap (PDF syntax: J, d, m and l operators). You 
should either implement the DrawInterface, or extend the 
VerticalPositionMark class. This allows you to draw dots using every 
possible operator available in the Adobe Imaging Model.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] How to retrieve page margins?

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 4:13, qplace schreef:
> How to retrieve the page margins from the existing document?
>
> I have PdfReader instance which I am using to get the page rectangle. I don't
> see the method that returns the margin sizes for the page. Is there such a
> method and how can I get the margins for a page where there is no text?
> Using "TextMarginFinder" apparently retrievs the margins of the existing text
> on a page. My situation is that the document I am reading have only fields and
> no text...
You should retrieved the coordinates of the fields (method 
getFieldPositions) and use that information.

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


Re: [iText-questions] Apend pdf, tiff, jpg or othe rimages to a master pdf

2010-12-17 Thread 1T3XT BVBA
Op 17/12/2010 9:13, tim clark schreef:
> Can anyone drop a hint as to how you can use the
>   iTextSharp.text.pdf.PdfSmartCopy  to append images
> &  create a new page in the pdfcopy document
Download chapter 6 of the Second Edition of "iText in Action"
from this page: http://affiliate.manning.com/idevaffiliate.php?id=223_212
(Chapter 6 is available for free.)

Go to 6.4.1 and read: there are two different versions of the addPage() 
method.
You can add blank pages if you use a Rectangle and a rotation as 
parameters, or...
This answers your second question.
Turn the page for the answer to your first question, and read "Adding 
content
with PdfCopy".

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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


[iText-questions] Apend pdf, tiff, jpg or othe rimages to a master pdf

2010-12-17 Thread tim clark
All
I had a task recently to create a master customer electronic billing 
document
the first document was a multipage pdf invoice the subsequent documents
were scanned 1 page  images in a variety of images formats.
Each master customer billing pdf document was later combine into a single
batch pdf document.

I choose to use  the  iTextSharp.text.pdf.PdfSmartCopy interface
to append the 1 pdf document to the master oPdfCopy
The use pattern in vb.net looks like this (w/o the declares)
& oFiles is an xml node structure with the files to combine

oPdfDoc=New iTextSharp.text.Document(PageSize.LETTER)
 oFileStream = New 
System.IO.FileStream(oFiles.GetAttribute("OutputFilePath"), 
IO.FileMode.Create, IO.FileAccess.ReadWrite)
 oPdfCopy = New iTextSharp.text.pdf.PdfSmartCopy(oPdfDoc, oFileStream)
 For Each oFile In oFiles.ChildNodes

  Select Case Path.GetExtension(oFile.GetAttribute("FilePath")).ToLower
Case ".jpg", ".png", ".bmp", ".gif", "tif", "wmf"
  oPdfImgDoc = New iTextSharp.text.Document(PageSize.LETTER)
  oStream = New System.IO.MemoryStream
  oPdfImgWri = 
iTextSharp.text.pdf.PdfWriter.GetInstance(oPdfImgDoc, oStream)
  oPdfImgWri.CloseStream = False
  oPdfImgDoc.Open() '//Open Document to write
  
'http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images
  Dim oImg As iTextSharp.text.Image = 
iTextSharp.text.Image.GetInstance(oFile.GetAttribute("FilePath"))
  oImg.ScalePercent(24.0F) 'scale% a std image from 72dpi to 
300dpi for pritning 72/300 * 100
  'oImg.ScaleToFit(oPdfImgDoc.PageSize.Width, 
oPdfImgDoc.PageSize.Height)
  'oImg.SetAbsolutePosition(oPdfImgDoc.PageSize.Width, 
oPdfImgDoc.PageSize.Height)
  oPdfImgDoc.Add(oImg)
  oPdfImgDoc.Close()
  oStream.Seek(0, IO.SeekOrigin.Begin)
  oPdfReader = New iTextSharp.text.pdf.PdfReader(oStream)

  For pageLoop = 1 To oPdfReader.NumberOfPages
oPdfCopy.AddPage(oPdfCopy.GetImportedPage(oPdfReader, 
pageLoop))
  Next
  oPdfCopy.FreeReader(oPdfReader)
  oPdfCopy.Flush()
Case ".pdf"
  oPdfReaderFile = New 
iTextSharp.text.pdf.RandomAccessFileOrArray(oFiles.GetAttribute("OutputFilePath")",
 
True)
 oPdfReader = New iTextSharp.text.pdf.PdfReader(oPdfReaderFile, 
Nothing)
 For pageLoop = 1 To oPdfReader.NumberOfPages
  oPdfCopy.AddPage(oPdfCopy.GetImportedPage(oPdfReader, 
pageLoop))
 Next
Next

The case statement above is a bit of a hack for images but it does work
but its not very efficient
So I struggled a bit to find an interface that exposed a full pdfwriter via
  iTextSharp.text.pdf.PdfSmartCopy interface so I could just
append images to the   iTextSharp.text.pdf.PdfSmartCopy interface to 
pdfwriter

This was  a couple of attempts that failed :(
 oPdfCopy.NewPage()
 oPdfCopy.Add(oImg)

then I tried this
 oPdfCopy.NewPage()
 oIndirectPageref = oPdfCopy.GetPageReference(iPageCnt)
 oPdfCopy.AddDirectImageSimple(sigImg, oIndirectPageref)

 but I could never get the image into the pdf pages

Can anyone drop a hint as to how you can use the
 iTextSharp.text.pdf.PdfSmartCopy  to append images
& create a new page in the pdfcopy document
It seems like AddDirectImageSimple would be the route to go
if I could properly create a new blank page using the pdfcopy & get
back an the coorect page reference but oPdfCopy.NewPage()
doers not seems to be the magic bullet :( 


--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
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