How to avoid a linebreak when I append a paragraph node?

I cant solve it. If the first child of my source document star with a Table or a Imagen it doesnt appear in the target document, but… if the source document start with text I have all the content including images or tables.

:frowning:I give up :frowning:

Thanks for your attention and dedication with this support forum.

@Jagovi Could you please attach your problematic source documents here for testing? I will check the issue and provide you more information.

I attach the inputs .docx and the Output doc with the 3 docs. As you can see if the first element is an image or a table it is missing, but if the image or the table is in the midle of the document it is recovered withou problems to the output document.

Thanks for your attention.

INPUT 1 WORKING.docx (4.0 MB)
INPUT 2 NOT WORKING.docx (4.0 MB)
INPUT 3 NOT WORKING.docx (4.0 MB)
OUTPUT.pdf (546.2 KB)

@Jagovi Thank you for additional information. If I understand your scenario properly, you are extracting content between Inicio_resumen and Fin_resumen bookmarks. If so, the last two documents does not work as expected because in the INPUT 2 NOT WORKING.docx table is placed before starting bookmark:


The same applies to INPUT 3 NOT WORKING.docx - the image is placed before the starting bookmark:

So it looks like the problem is no in your code, but in the input documents. You can use DocumentExplorer demo application to explore document structure.

Thanks!!
At least we know that the code is working as it should.
Do you have any idea about how correct the documen?
I am using Document Explore as you recommended me but I am getting confused results…
If i see the Document level I get this:

But if I inspect the table is before the starter marker…
Why is it happening?

@Jagovi To correct the document you should move the starting bookmark into the correct location.
Alternatively, if whole document represents content that should be inserted, just use whole document’s content instead of extraction content between bookmarks.

Hi @alexey.noskov!
One more doubt, to avoid opening a new thread, I expose it here.
Using the following code:

for (int j = 0; j < parrafoArrays.length; j++)
{
    if (parrafoArrays[j].getNodeType() == NodeType.PARAGRAPH)
    {
        Paragraph para = (Paragraph)parrafoArrays[j];
        while (para.hasChildNodes())
            builder.insertNode(para.getFirstChild());
        if (j < (parrafoArrays.length - 1))
        {
            builder.writeln();
        }
    }
    else
    {
        builder.writeln();
        builder.getCurrentParagraph().getParentNode().insertBefore(parrafoArrays[j], builder.getCurrentParagraph());
    }
}

I have a problem and it is that when doing:

builder.insertNode(para.getFirstChild());

It doesn’t respect the format. I would like make it maintaining the format that the target document has, not the source document.

Summarizing:

I have the next marker with format:

@@recoveryResume(style{Font:Arial;red;size:11;align:JUSTIFY;fonttype:normal}[RESUME])|

But the output document has the style of the [RESUME] document. I need:
If there is a format specified before the mark [RESUME] use it. If there is no format, use the format of the last node write in the document with the builder.

How could I make it?

Thanks!

@Jagovi DocumentBuilder.insertNode inserts the specified node as is, it does not change it. For example if the inserted node is a Run of text it might have explicit formatting set. If you need the inserted Run inherit formatting from the style applied to the paragraph, you can clear formatting applied to the Run. You can use Font.clearFormatting() method.