【发布时间】:2013-11-19 03:47:33
【问题描述】:
我有一条很长的线路,想转换成多条线路。 截至目前,该文本超出了我的 pdf 格式。
int show_data(){
YPOS -= 10;
NextPage();
double ypos = YPOS;
double maxWidth = HPDF_Page_GetWidth(currentpage) - (m_Margin * 2);
double indentStart = 2 * m_Margin;
double xpos = indentStart;
bool thereIsText = (text.length() > 0);
int textPos = 0;
string newText;
while (thereIsText) {
// maxWidth-xpos is the max length of text allowed per line;
newText = text.substr(textPos);
HPDF_TextWidth spacewidth =
HPDF_Font_TextWidth(font, (const HPDF_BYTE *) " ", 1);
HPDF_TextWidth tw =
HPDF_Font_TextWidth(font, (const HPDF_BYTE *) newText.c_str(),
newText.length());
textPos += (newText.length() + 1);
HPDF_Page_BeginText(currentpage);
loginfo<<xpos<<ypos<<endl;
HPDF_Page_SetFontAndSize (currentpage, font, 24);
HPDF_Page_SetLineWidth(currentpage, 80);
HPDF_Page_MoveTextPos(currentpage,-220, ypos);
//HPDF_Page_MoveToNextLine
//HPDF_Page_TextOut(currentpage,xpos,ypos, newText.c_str());
//HPDF_Page_MoveTo(currentpage, 120, 195);
//HPDF_Page_MoveTextPos (currentpage, 20, 20);
HPDF_Page_ShowTextNextLine(currentpage, newText.c_str());
HPDF_Page_EndText(currentpage);
if ((unsigned int) textPos >= text.length())
thereIsText = false;
ypos -= 10;
loginfo<<" ypos ... "<<ypos<<endl;
loginfo<< " m_Margin.... "<<m_Margin<<endl;
/*if (ypos <= m_Margin) {
NextPage();
ypos = HPDF_Page_GetHeight(currentpage) - m_Margin;
}*/
xpos = m_Margin;
}
YPOS = ypos;
}
【问题讨论】:
-
这个问题是关于如何在不破坏打印边界的情况下向 libharu 生成的 pdf 文件显示/打印长行,而不是让 c/c++ 将长行分成几个小行吗?
标签: c++ c pdf-generation libharu