2017-10-24 11 views
0

HTML 코드를 JPEG 이미지로 변환하려고합니다. 그것은 일종의 일이지만, 바코드로 할려고 할 때 아닙니다.NReco 이미지 생성기가 바코드를 올바르게 쓰지 않습니다.

서버 측, 내가 사용 : 나는 웹 페이지를 표시 할 때

내가 CODE128 프로토콜과 EAN133 바코드를 인코딩하고있어, 그것은 작동 (나는 HttpUtility.HtmlEncode(code_barre)를 사용하므로 바코드 잘 해석됩니다) 다음, 나는 바코드를 표시하는 바코드 폰트를 사용하고 있는데, 뭔가가 내 이미지 문제입니다 그건 : 당신이 볼 수 있듯이

enter image description here

, 그것은 바코드 "일반 텍스트"좋은 형식입니다, 그리고 다음과 CSS :

@font-face { font-family: 'code_128regular'; src: url('/Assets/Fonts/code128-webfont.eot'); src: url('/Assets/Fonts/code128-webfont.eot?#iefix') format('embedded-opentype'), url('/Assets/Fonts/code128-webfont.woff2') format('woff2'), url('code128-webfont.woff') format('woff'), url('/Assets/Fonts/code128-webfont.ttf') format('truetype'), url('/Assets/Fonts/code128-webfont.svg#code_128regular') format('svg'); font-weight: normal; font-style: normal;} .test{font-family:'code_128regular'; font-size:70px;} 

나는이 될해야합니다

enter image description here

을하지만 내가 IronPDF을 가진 PDF를 생성 할 때 작동하는 반면 나는 상대 경로로 부트 스트랩 CSS를 가져올 경우에도하지 않습니다

관심

감사

편집 :

<html> 
<head> 
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> 
    <link rel='stylesheet' type='text/css' href='Assets/Bootstrap/css/bootstrap.min.css'> 
    <script type='text/javascript' src='Assets/Bootstrap/js/bootstrap.min.js'></script> 
</head> 
<style> 
    @font-face { 
     font-family: 'code_128regular'; 
     src: url('/Assets/Fonts/code128-webfont.eot'); 
     src: url('/Assets/Fonts/code128-webfont.eot?#iefix') format('embedded-opentype'), url('/Assets/Fonts/code128-webfont.woff2') format('woff2'), url('code128-webfont.woff') format('woff'), url('/Assets/Fonts/code128-webfont.ttf') format('truetype'), url('/Assets/Fonts/code128-webfont.svg#code_128regular') format('svg'); 
     font-weight: normal; 
     font-style: normal; 
    } 

    .test { 
     font-family: 'code_128regular'; 
     font-size: 70px; 
    } 
</style> 
<center><p class='test'>&#204;MXCUTGRIP305-07D&#206;</p><p>MXCUTGRIP305-07</p></center> 
</html> 
: 여기에 생성 된 HTML이다
+0

무엇 생성 된 HTML 모습입니까? – VDWWD

+0

나는 당신을 보여주기 위해 편집 하겠지만, 서버 쪽에서 생성 되었기 때문에 읽기가 조금 어렵다 – alexay68

+1

코드는 시도 할 때 작동한다. 확장 기능'.eot','.woff' 및'.woff2'가 IIS에서 허용되는 MIME 유형인지 확인할 수 있습니까? 그렇지 않으면 브라우저에 파일이 제공되지 않고 404가 표시됩니다. – VDWWD

답변

1

NReco ImageGenerator는 내부적으로 wkhtmltoimage 명령 줄 도구를 사용하므로 실제로 동일한 동작을 기대할 수 있습니다. 귀하의 경우에는 사용자 정의 글꼴이 wkhtmltoimage에 의해 무시되는 것처럼 보입니다. 우선 wot, woff2 또는 ttf 글꼴 파일을 eot 대신 사용하십시오. HTML을 .NET 문자열로 받아들이는 "GenerateImage"메소드를 사용하면 모든 외부 참조가 절대적이어야합니다.

다음 HTML 템플릿 (I 구글 글꼴에서 "리브레 바코드 128"사용했습니다) 나를 위해 잘 작동 :

<html> 
<head> 
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> 
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Libre+Barcode+128&amp;lang=en" /> 
</head> 
<style> 
    .test { 
     font-family: 'Libre Barcode 128'; 
     font-size: 70px; 
    } 
</style> 
<center><p class='test'>&#204;MXCUTGRIP305-07D&#206;</p><p>MXCUTGRIP305-07</p></center> 
</html> 
+0

외부 RESSource를 사용하기 때문에 원하는 내용이 아닙니다.하지만 해결할 수 있습니다. – alexay68

+0

@ alexay68 그냥 ​​google을 엽니 다. fonts url (https://fonts.googleapis.com/css?family=Libre+Barcode+128 & lang = ko)이 경우는 보통 "글꼴 - 얼굴"정의 (이 경우 woff2)라는 것을 알 수 있습니다. 로컬 파일도 잘 작동합니다. –

+0

그걸 보았습니다 ... 어쩌면 내 글꼴을 찾을 수 없기 때문에 (예를 들어 누락 된 일부 서버 매핑 속성) NReco에서 로컬로 인식하지 못했지만 걱정하지 마세요. 작동하는 한 내 글꼴은 그렇지 않습니다. 정말 내 모든 ressources에 손이없는 경우 중요합니다 (즉, Google 글꼴, 그것은 tommorow 이동하지 않습니다) – alexay68