我有跟踪并获得很长的线路,想要转换成多行。截至目前,该文本超出了我的 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;
}