2017-09-21 5 views
2

J'ai ajouté le code à itext sharp pour envelopper le texte continu. ici par exemple une url. Ces css fonctionne très bien lorsque vous travaillez dans un navigateur Web, mais quand j'exporte en pdf l'url ne pas envelopper.Wraping texte continu dans Itext forte

Je ne suis pas en mesure de localiser le problème exact.

image pour le comportement de référence de la vue en ligne et pdf:

Image for reference behavior of the online and pdf view

Est-il possible d'envelopper l'URL avec css

.background-color-dark-blue { 
 
    background-color: #485679; 
 
} 
 
.color-light { 
 
    color: #fff !important; 
 
} 
 

 

 
.white-space-pre-wrap a { 
 
    word-break: break-all !important; 
 
    word-wrap: break-word; 
 
    word-wrap: break-word !important; 
 
    
 
} 
 
.break-all { 
 
    word-break: break-all; 
 
    word-wrap: break-word; 
 
} 
 

 
.url-style a { 
 
    /*font-size: 14px;*/ 
 
    line-height: 1.3; 
 
    color: #2a99d4; 
 
    font-weight: 700; 
 
    text-decoration: none; 
 
    margin-top: 0px !important; 
 
}
<table> 
 
               <colgroup> 
 
                <col class="col-3"> 
 
                <col class="col-4"> 
 
                <col class="col-5"> 
 
               </colgroup> 
 
               <thead> 
 
                <tr class="background-color-dark-blue "> 
 
                 <th class="color-light"> 
 
                  Document Name</th> 
 
                 <th class="color-light"> 
 
                  Document Description</th> 
 
                 <th class="color-light"> 
 
                  Location/Link</th> 
 
                </tr> 
 
               </thead> 
 
               <tbody> 
 
                
 
             <tr class="bg-color-lighter"> 
 
              <td class="va-top">FATF 40 Recommendations</td> 
 
              <td class="va-top">Global standard for AML/CFT published by the Financial Action Task Force </td> 
 
              <td class="review-report-url-fix padding-left-5 break-all va-top"> 
 
               <div class="break-all va-top"> 
 
               <a id="SiteContentPlaceHolder_AppendicesReviewControl_ReferenceDocumentListView_ReferenceDocumentLink_0" title="http://www.fatf-gafi.org/publications/fatfrecommendations/ 
 
http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html" class="url-style white-space-pre-wrap" href="http://www.fatf-gafi.org/publications/fatfrecommendations/%0d%0a%20http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html" target="_blank">http://www.fatf-gafi.org/publications/fatfrecommendations/ 
 
http://www.fatf-gafi.org/publications/fatfrecommendations/documents/risk-based-approach-banking-sector.html</a> 
 
                </div> 
 
               
 
              </td> 
 

 
             </tr> 
 
            
 
             <tr class="bg-color-dashboard-table"> 
 
              <td class="va-top">Risk Based Approach Guidance for Legal Professionals</td> 
 
              <td class="va-top">Guidance on the AML/CFT Risk Based Approach for lawyers and the legal profession</td> 
 
              <td class="review-report-url-fix padding-left-5 va-top"> 
 
               <div class="break-all va-top"> 
 
               <a id="SiteContentPlaceHolder_AppendicesReviewControl_ReferenceDocumentListView_ReferenceDocumentLink_1" title="http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html" class="url-style white-space-pre-wrap" href="http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html" target="_blank">http://www.fatf-gafi.org/publications/fatfrecommendations/documents/riskbasedapproachguidanceforlegalprofessionals.html</a> 
 
                </div> 
 
               
 
              </td> 
 

 
             </tr>         
 
            
 
               </tbody> 
 
              </table>

+0

Juste pour vous assurer: Quelle version iText utilisez-vous? 5.5.x avec 'XmlWorker' ou 7.0.x avec' HtmlConverter'? – mkl

+0

Je viens de regarder les détails d'un billet récent dans le système de soutien iText, vous êtes le même client qui a signalé cela. Mon collègue qui est en charge du problème vous donnera une solution via JIRA, nous ne publierons pas de solution sur Stack Overflow. Vous êtes toutefois autorisé à copier cette solution dans Stack Overflow une fois que vous l'avez obtenue. –

+0

J'utilise Itext version 7.0 –

Répondre

0

iText version 7.0 a une fonction de bibliothèque inbuild

SetSplitCharacters (caractères fragmentés ISplitCharacters);

Donc, pour diviser les caractères en iText 7 utiliser le code

public string SplitChars { get; set; } = ".+-/"; 
var document = new Document(pdf, PageSize.LETTER, false) 
document.SetSplitCharacters(new CustomSplitCharacters(SplitChars)); 

maintenant une url continue cassera à chaque + -./Quand il est à la fin de la cellule de table

url reffer pour fonctions de bibliothèque

http://itextsupport.com/apidocs/itext7/7.0.4/com/itextpdf/layout/ElementPropertyContainer.html