Hi Aspose support team,
we are creating PDF dynamically, tested Aspose and would purchase it if it is possible to get the Y offset over the page at the end of an added text or html block in order to place the next object at x,y coordinate with a custom y-gap; is it possible to determine this y-position to manage the y-gaps between the objects?
i.e. if I define a FloatingBox with (width,height) of (500,100) and place it at (50,100) is it possible to get the y-offset of HtmlFragment-end added to FloatingBox since the HtmlFragment depending on its content could be less or greater as 200?
Thanks in advance
Slava
Hi Slava,
Document doc = new
Document();
Aspose.Pdf.Text.Font font = Aspose.Pdf.Text.FontRepository.FindFont(“Arial”);
doc.PageInfo.DefaultTextState.Font = font;
Aspose.Pdf.Page page = doc.Pages.Add();
Aspose.Pdf.FloatingBox fb = new Aspose.Pdf.FloatingBox();
fb.Margin.Top = 72;
Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment();
textFragment.Text = "Aspose.Pdf";
//frag.TextState.Font = font;
textFragment.TextState.FontSize = 9;
textFragment.TextState.LineSpacing = 12f;
textFragment.IsInLineParagraph = true;
fb.Paragraphs.Add(textFragment);
Aspose.Pdf.Text.TextFragment textFragment1 = new Aspose.Pdf.Text.TextFragment();
textFragment1.IsInLineParagraph = false;
textFragment1.Text = "For .NET 10.8.0";
//frag1.TextState.Font = font;
textFragment1.TextState.FontSize = 12;
textFragment1.TextState.LineSpacing = 25f;
fb.Paragraphs.Add(textFragment1);
page.Paragraphs.Add(fb);
Aspose.Pdf.Text.TextFragment textFragment2 = new Aspose.Pdf.Text.TextFragment();
textFragment2.Text = "y-offset at the end of text of an added Paragraph";
//frag.TextState.Font = font;
textFragment2.TextState.FontSize = 9;
textFragment2.TextState.LineSpacing = 12f;
textFragment2.IsInLineParagraph = true;
page.Paragraphs.Add(textFragment2);
doc.Save(myDir + "Text_LineSpacing.pdf");
Hi Tital,
thanks a lot for your prompt reply,
here is the sample code I use:
HtmlFragment titel = new HtmlFragment(a_pretty_big_html_content);
com.aspose.pdf.FloatingBox box2 = new com.aspose.pdf.FloatingBox(580,10);
box2.getParagraphs().add(titel);
box2.setTop(400);
box2.setLeft(-80);
page.getParagraphs().add(box2);
the problem is that the FloatingBox here defined with height of 10 points (actually I could make 2 or 200); but the html content is placed dynamically over the defined y-boundry of the box so I need to know the y-coordinate or current y-offset at the end of html-block in order to place the next object right beneath the html-block, i,e.:
html_content = “abc def ghi jkl mno pqr stu vwx”;
ready pdf:
-----------------------------
abc def
ghi jkl
mno pqr
stu vwx <-here I need the y-offset of this line to place the next object right beneath it with no gap or overlapping
may be there are some low level API methods to get this information?
bst rgds
Slava
Hi Slava,
Document doc = new Document();<o:p></o:p>
Page page=doc.getPages().add();
String html_content = "abc def ghi jkl mno pqr stu vwx";
HtmlFragment titel = new HtmlFragment(html_content);
com.aspose.pdf.FloatingBox box2 = new com.aspose.pdf.FloatingBox(580, 10);
box2.getParagraphs().add(titel);
box2.setTop(400);
box2.setLeft(-80);
page.getParagraphs().add(box2);
page.getParagraphs().add(new HtmlFragment("2abc def ghi jkl mno pqr stu vwx"));
doc.save("E:/Data/floatingbox_output.pdf");
Hi Tilal,
my problem is that by printing an invoice constiting of many positions containing HTML-Texts I cannot procceed to that next page without knowing the current end position of a printed object
Hi Slava,