Jason Berk | 9 Feb 20:07
Favicon

PdfPTable keepTogether with skipped header rows

I noticed if I create a table with some header rows and set
skipFirstHeader(true) and then set keepTogether(true) and add the table
to the document using doc.add(table) the header rows are being
considered in the calculation to determine if the table fits on the
current page...even if they aren't going to print when the table is
rendered.

To apply example numbers, assume you have a table with 5 rows all 1 inch
tall...keepTogether(true)...skipFirstHeader(true)

Row 1 and 2 are header rows

Rows 3,4,5 are body rows

The table is 5" tall

If you have 4" left on the current page, there technically is enough
room to print the table, because the headers are skipped and only the
three body rows would print.  It appears like the two header rows are
cause the table to be pushed to the next page because a 5" table can't
be rendered in a 4" space with keepTogether(true).

Is this by design?  Can someone else confirm this?

I'm using iText 5.1.2 

Jason Berk
jberk <at> purduefed.com
www.purduefed.com
800.627.3328 x8902
(Continue reading)

gdn13 | 9 Feb 16:25
Gravatar

Split PDF by plain Bookmark

Hi,
My need is to be able to split a PDF between 2 bookmarks. BUT the difficulty
is that the bookmarks have been created with no parameters, only the 'Title'
property is set...
I am currently using the SimpleBookmark static class to get all the
bookmarks. And when I meet the wanted bookmark I would like to know the page
number. But as said before the bookmark contains only the Title (no Page
property set)
Do you have a solution for my need ?
I could have aske the question in another way: "how to copy all the content
between 2 bookmarks" ?
Thanks a lot.
Gregory

--
View this message in context: http://itext-general.2136553.n4.nabble.com/Split-PDF-by-plain-Bookmark-tp4373196p4373196.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
(Continue reading)

Myriam Economou | 9 Feb 15:44
Picon
Gravatar

XMLWorker : HTML to PDF problem with external css

Hi,

For a project I have to parse an HTML page into a pdf using XMLWorker and I am encountering a problem since my external css file is not taken into consideration.
I had no problem parsing a simple HTML file, an HTML file with CSS in the tags, HTML file with CSS in the <head> but the external CSS file is not working.
I am using Visual studio to develop in C# and both my files (HTML and CSS) are included in the project and are located in the same folder as the other files of the project so they should find each other easily....or?:)
I attached my files to this mail.

I thank you in advance for any hints you could gave me. I spent already 2 days browsing the documentation and internet to find similar issues but in their example they all put CSS in the <head> tag.

Have a nice day

Myriam

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.tool.xml;
using iTextSharp.tool.xml.html;
using iTextSharp.tool.xml.parser;
using iTextSharp.tool.xml.css;
using iTextSharp.tool.xml.pipeline.html;
using iTextSharp.tool.xml.pipeline.css;
using iTextSharp.tool.xml.pipeline.end;

    class Class1
    {
        public void createInvoiceFromHtmlUsingXmlWorker()
        {
            //Step 1 : basics
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            // Create a writer that listens to the document and direct and XML-Stream to a file
            PdfWriter writer = PdfWriter.GetInstance(document, new
FileStream("C:\\Users\\myreco\\InvoiceFromHtmlXmlWorker.pdf", FileMode.Create));
            document.Open();
            //HtmlPipeline
            HtmlPipelineContext htmlContext = new HtmlPipelineContext();
            htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            //CSS stuff
            ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);
            //Pipeline
            IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new
PdfWriterPipeline(document, writer)));
            //XMLWorker
            XMLWorker worker = new XMLWorker(pipeline, true);
            //and...we parse
            XMLParser p = new XMLParser(worker);
            p.Parse(((Stream)new
FileStream("C:\\Users\\myreco\\VisualStudio\\PremiereApplication\\ConsoleApplication1\\test.html", FileMode.Open)));
            //Close document
            document.Close();
        }

    }

Northwind Traders Receipt

Thank you for shopping at Northwind Traders. Your order details are below.

Order Information

Items In Your Order

Banana king

Site du Zero

Thank you for your business! If you have any questions about your order, please contact us at 800-555-NORTH.

Attachment (style.css): text/css, 22 bytes
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
Elias | 8 Feb 13:17
Picon
Gravatar

Bug in PDFX1A2001?

Hello Folks,

I'm using imagemagick to convert from RGB to CMYK and it is inserted a new
pdf document with iText checking the PDFX1A2001 conformance, this is my
code:

IMOperation op = new IMOperation();
op.addImage(_pathIn);
op.p_profile("*");
op.profile(DEFAULT_PATH_ICCRGBPROFILE);
op.profile(DEFAULT_PATH_ICCCMYKPROFILE);
op.strip();
op.addImage("-");
		
//Convert to BufferedImage
ConvertCmd cmd = new ConvertCmd();
Stream2BufferedImage s2b = new Stream2BufferedImage();
cmd.setOutputConsumer(s2b);
cmd.run(op);
BufferedImage imageTransformed = s2b.getImage();

//To PDF
Document document = new Document(); 
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(_pathOut));
writer.setPDFXConformance(PdfWriter.PDFX1A2001);
writer.setPdfVersion(PdfWriter.VERSION_1_3);
document.open();
PdfContentByte content = writer.getDirectContent(); 
Image iTextImg = Image.getInstance(imageTransformed, null);
iTextImg.setDpi(300,300);
iTextImg.setSmask(false);
iTextImg.setAbsolutePosition(0,0);
content.addImage(iTextImg);
document.close();

When the image goes to be inserted with content.addImage, the debugger throw
a exception:
...
Exception in thread "main" com.itextpdf.text.DocumentException:
com.itextpdf.text.pdf.PdfXConformanceException: Colorspace RGB is not
allowed.
	at com.itextpdf.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1269)
	at com.itextpdf.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1110)
	at com.itextpdf.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1094)
	...
Caused by: com.itextpdf.text.pdf.PdfXConformanceException: Colorspace RGB is
not allowed.

I'm sure that the code to transform from RGB to CMYK is right,

Somebody can I help me, please?.

Thanks in advance

--
View this message in context: http://itext-general.2136553.n4.nabble.com/Bug-in-PDFX1A2001-tp4369222p4369222.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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

Raffaele | 8 Feb 10:24
Picon
Favicon
Gravatar

Informations regarding iText methods

Hi everybody,

i would to know whati is the "byte[] secondDigest" into the method
GetEncodedPKCS7.

If you know, how is calculated and when.

Thanks!

Raffaele.

--
View this message in context: http://itext-general.2136553.n4.nabble.com/Informations-regarding-iText-methods-tp4368888p4368888.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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

Gabrielle Manaloto | 8 Feb 09:21
Gravatar

Update XML node of PDF using iTextSharp

Hi,

 

We would like to ask if there is any way to update a form using iTextSharp which selects it by a node?

 

AcroFields.Xfa.DatasetsNode.SelectSingleNode("//xfa:data/form/inventoryNo", nsmanager)

 

We will like to update this node through c#. Thanks.

 

Regards,

 

Gabrielle Manaloto

LR Application Support

Wallem Innovative Solutions

Email: gabm <at> wallem.com

Mobile: +639228950445

Office: +63458934131

 

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
Scott Polk | 7 Feb 18:07
Picon
Gravatar

Issue reading form field names from a Dynamic XML Form using iText 5.1.3

Hi all –

 

I have attempted many times in many different ways to read the form field names from a Dynamic XML Form created in Adobe LiveCycle Designer v8.2 and have been unsuccessful.  I found http://what-when-how.com/itext-5/introducing-the-xml-forms-architecture-xfa-part-1-itext-5/ which has an example of how to read field names from an XFA Form, but when I attempt to run it, it does not show any field names.  Here is my code, and I have attached my PDF file that I am testing with.  I am at a total loss, so any help is appreciated.

 

Note that this code works perfect for a Static Form.

 

import java.io.IOException;

import java.util.HashMap;

import java.util.Map;

import java.util.Set;

 

import javax.swing.JOptionPane;

 

import com.itextpdf.text.pdf.AcroFields;

import com.itextpdf.text.pdf.PdfReader;

import com.itextpdf.text.pdf.XfaForm;

 

public class MyPDFReader {

       public static Map<String, String> GetFormFields(String filePath) {

              PdfReader pdfDoc = null;

              AcroFields fieldList = null;

              Set<String> fields = null;

              Map<String, String> pdfFields = null;

              try {

                     pdfDoc = new PdfReader(filePath);

                    

                     fieldList = pdfDoc.getAcroFields();

                     fields = fieldList.getFields().keySet();

                     String allFields = "";

                     pdfFields = new HashMap<String, String>();

                     XfaForm xfa = fieldList.getXfa();

                     System.out.println( xfa.isXfaPresent() ? "XFA Form" : "AcroForm");

 

                     for (String key : fields) {

                           allFields += key.substring(key.lastIndexOf(".") + 1, key.lastIndexOf("[")) + "\n";

                           pdfFields.put(key.substring(key.lastIndexOf(".") + 1, key.lastIndexOf("[")), key);

                     }

                    

                     JOptionPane.showMessageDialog(null, allFields, "PDF Fields", JOptionPane.INFORMATION_MESSAGE);

              } catch (IOException ex) {

                     JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);

              } finally {

                     if (pdfDoc != null) {

                           pdfDoc.close();

                           pdfDoc = null;

                     }

                     if (fieldList != null) { fieldList = null; }

              }

             

              return pdfFields;

       }

}

Attachment (myTemplate.pdf): application/pdf, 78 KiB
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
Phil Newman | 6 Feb 19:08
Picon

under content watermark hidden behind text block

Hi. I am trying to add a watermark underneath the text in a document created by the LIveDocx service. The
watermark is being hidden behind the text area. It seems the text area has a white background color.
I also tried PdfCopy ing the page into a new document as an image and setting the transparency to knock out the
white, but it didn't work. I cannot get rid of the white behind the text so that the watermark displays.
Is there another way to insert an image in between the text and any background graphics?
I can supply the source PDF if it helps.

Thanks.

Phil Newman
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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

Maxy.erMayank | 6 Feb 18:59
Picon
Gravatar

Urgent: endHeaders, resetHeader, setOffset and fitsPage missing from iText 5.1.3

Hello, I am using iText version 2.0.3 and converting my code into 5.1.3.

However, I can't find reference to few methods, looks like it has removed.

It would be much appreciated for any suggestions and example.

I can't find reference for Document.resetHeader() and PdfWriter.fitsPage() method. One of the post is talks about to use ColumnText but I can't find any example.

Is setSpacingBefore/setSpacingAfter correct replacement for setOffset method and setHeaderRows for endHeaders ?

Thank you for all your time and concerns.

Mayank

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
Kristjan Košič | 6 Feb 13:53
Picon
Gravatar

XMLWorker and correct encoding, or embedding of fonts

Dear all,

I went thru all the possible documentation and googled stuff, now I am writing for help to the itext masters :)

I am using XMLWorker to generate PDF from basic html. The conversion works great the only problem is with the fonts, and I tried various ways (from my own factory, to some others samples). 
My custom font factory(code is below) works with HTMLWorker, but not with XMLWorker, which does also better parsing...

So my question is what is the best practice for embedding a font, and setting cp1250 encoding for special Slovenian characters? This encoding and font can be for the whole document.. 

My code is below... Looking forward to you answer...

Kind regards...
Kristjan

----- Conversion code:
********************************************
            FontFactory.registerDirectories();
            FontFactory.registerDirectory("/Temp/fonts");
            FontFactory.setFontImp(new DefaultFontProvider("Arial")); //my implementation of font factory, where I also override encoding to cp1250. this fa

            //??do I still need to additionaly register font here... 

            Document document = new Document();
            InputStream inputStringAsStream = new ByteArrayInputStream(pdfContents.getBytes());

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));
            document.open();

            HtmlPipelineContext htmlContext = new HtmlPipelineContext();
            htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
            htmlContext.setImageProvider(new AbstractImageProvider() {

                <at> Override
                public String getImageRootPath() {
                    // TODO Auto-generated method stub
                    return null;
                }
            });
            htmlContext.setLinkProvider(new LinkProvider() {

                <at> Override
                public String getLinkRoot() {
                    // TODO Auto-generated method stub
                    return null;
                }
            });
            CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
            Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, writer)));
            XMLWorker xworker = new XMLWorker(pipeline, true);
            XMLParser p = new XMLParser(xworker);
            p.parse(inputStringAsStream);
            document.close();

********************************************
/// Class custom font factory
// font factory code
class DefaultFontProvider extends FontFactoryImp {
        private String _default;

        public DefaultFontProvider(String def) {
            _default = def;
        }

        public Font getFont(String fontName, String encoding, boolean embedded, float size, int style, BaseColor color, boolean cached) {
            if (fontName == null || size == 0) {
                fontName = _default;
            }

            return super.getFont(fontName, "cp1250", embedded, size, style, color, cached);
        }
    }
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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
RIchard Hammond | 4 Feb 18:13
Picon

PDFTextExtractor returns an exception - 'Input string was not in a correct format" when parsing this file

Hello
 
 
Attached is the C# program (as a .txt file)   and the PDF file it fails on.
 
 
I have - in fact - run this PDF through another text converter and it works fine.
 
 
So my question is - any idea(s) why Itext can't or won't parse it?
 
 
Thanks in advance
 
 
Richard
 
 
Attachment (bill04December2011.zip): application/zip, 67 KiB
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
iText-questions mailing list
iText-questions <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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

Gmane