나는 새로운 라인을 얻기 위해 노력하고 있지만 사용하는 경우 \ n은 \ 연구 \ n (작동하지 않습니다)PDFsharp 줄 바꿈
gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230, 95);
같은 문자열로 뭔가를 추가하여 새로운 라인을 가지고 어떤 식 으로든 도움이되지 않습니다
이 작동하지 않습니다.
나는 새로운 라인을 얻기 위해 노력하고 있지만 사용하는 경우 \ n은 \ 연구 \ n (작동하지 않습니다)PDFsharp 줄 바꿈
gfx.DrawString("Project No \n" + textBoxProjNumber.Text, fontUnder, XBrushes.Black, 230, 95);
같은 문자열로 뭔가를 추가하여 새로운 라인을 가지고 어떤 식 으로든 도움이되지 않습니다
이 작동하지 않습니다.
XTextFormatter 클래스를 사용해 보셨습니까?
는 여기를 참조하십시오 : http://www.pdfsharp.net/wiki/TextLayout-sample.ashx
코드 스 니펫 :
내가 가진 정의 우측 측면 제한 및 결정 :
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold);
XTextFormatter tf = new XTextFormatter(gfx);
XRect rect = new XRect(40, 100, 250, 220);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);
우리는 왜 사각형이 필요합니까? –
이것은 작동합니다. 감사합니다. 한 걸음 더 나아가서는 migradoc에서 단락이 페이지보다 길고 자동으로 페이지 나누기를 삽입하는 것을 감지하는 방법 –
방금 찾은 것 pdfsharp는 더 나은 라이브러리로 대체되었습니다.) 그러나 VB.net에서는 + vbNewLine을 사용하지 말아야합니다./n – ShiftyThomas
이 내가 사각형 클래스를 사용하여 포함하지 않았다 것입니다 현재 문자열이 설정된 경계보다 큰지 여부 그것이 있었다면, 나는 그것을 썼다. 그렇지 않으면 계속 추가했습니다.
foreach (string field in temp)
{
if (field == string.Empty)
{
continue;
}
else
{
tempSB.Clear();
tempSB.Append(sb.ToString());
tempSB.Append(field).Append(", "); //append the incoming value to SB for size testing
if (gfx.MeasureString(tempSB.ToString(), defaultFont).Width > 500) //if the incoming string is bigger than the right bounds, write it and clear SB
{
gfx.DrawString(sb.ToString(), defaultFont, blackBrush, 50, currentLine + defaultSpacing);
currentLine += 15;
sb.Clear();
sb.Append(" " + field).Append(","); //add the overflow to the beginning of the next line
}
else
{
sb.Append(field).Append(", "); //if it is not too big, append it
}
}
}
if (sb.Length > 0 && sb[sb.Length - 1] == ',') sb.Length--;
gfx.DrawString(sb.ToString(), defaultFont, blackBrush, 50, currentLine + defaultSpacing); //write out whatever has not already been written out
나는이 질문에 늦었 알고 있지만 나는 누군가를 도울 수 있기를 바랍니다.
'XTextFormatter' 클래스와 비슷한 접근 방식이지만 유연성이 떨어집니다. –
일종의 콘솔 모드라면 DrawString()을 두 번 호출하면 어떨까요? – BlackBear
죄송합니다. –
DrawString (Project No "); DrawString (textBoxProj .....); – BlackBear